1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-26 08:14:38 +01:00

Only add full initialized windows to the window list (#24859)

This removes the possibility of a race condition where a window is added to the window list but OnOpen has not been called. Many windows use OnOpen to set up required members so if say OnDraw is called it may use uninitialized members. For an example see ProgressWindow.
This commit is contained in:
Garrett Leach
2025-08-01 10:03:30 -05:00
committed by GitHub
parent ee23d47276
commit a8767ec4d8

View File

@@ -895,34 +895,33 @@ public:
}
}
auto itNew = g_window_list.insert(itDestPos, std::move(wp));
auto w = itNew->get();
// Setup window
w->classification = cls;
w->flags = flags;
wp->classification = cls;
wp->flags = flags;
// Play sounds and flash the window
if (!(flags & (WF_STICK_TO_BACK | WF_STICK_TO_FRONT)))
{
w->flags |= WF_WHITE_BORDER_MASK;
wp->flags |= WF_WHITE_BORDER_MASK;
OpenRCT2::Audio::Play(OpenRCT2::Audio::SoundId::WindowOpen, 0, pos.x + (windowSize.width / 2));
}
w->windowPos = pos;
w->width = windowSize.width;
w->height = windowSize.height;
w->min_width = windowSize.width;
w->max_width = windowSize.width;
w->min_height = windowSize.height;
w->max_height = windowSize.height;
wp->windowPos = pos;
wp->width = windowSize.width;
wp->height = windowSize.height;
wp->min_width = windowSize.width;
wp->max_width = windowSize.width;
wp->min_height = windowSize.height;
wp->max_height = windowSize.height;
w->focus = std::nullopt;
wp->focus = std::nullopt;
ColourSchemeUpdate(w);
w->Invalidate();
w->OnOpen();
return w;
ColourSchemeUpdate(wp.get());
wp->Invalidate();
wp->OnOpen();
auto itNew = g_window_list.insert(itDestPos, std::move(wp));
return itNew->get();
}
/**