fix: allow window list edits at any time

Slightly tweak the logic of the WindowSystem Draw() to make a shallow copy of the
window list before iterating over it. This allows for the list to be edited at
any time, but has a trade-off that modifications to the list won't take effect
until the next frame, which is negligible and would have been the case anyways.

This change does not break any existing APIs, and should incur minimal (if any)
performance penalty.
This commit is contained in:
Kaz Wolfe 2022-04-12 18:07:22 -07:00
parent dbbcc0f287
commit 40e6289321
No known key found for this signature in database
GPG key ID: 258813F53A16EBB4

View file

@ -106,7 +106,8 @@ namespace Dalamud.Interface.Windowing
if (hasNamespace)
ImGui.PushID(this.Namespace);
foreach (var window in this.windows)
// Shallow clone the list of windows so that we can edit it without modifying it while the loop is iterating
foreach (var window in this.windows.ToArray())
{
#if DEBUG
// Log.Verbose($"[WS{(hasNamespace ? "/" + this.Namespace : string.Empty)}] Drawing {window.WindowName}");