bugfix(gui): Remove destroyed windows from modal stack - #3224
bugfix(gui): Remove destroyed windows from modal stack#3224tintinhamans wants to merge 1 commit into
Conversation
PR Summary by QodoRemove destroyed windows from GUI modal stacks
AI Description
Diagram
High-Level Assessment
Files changed (4)
|
Code Review by Qodo🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)
Great, no issues found!Qodo reviewed your code and found no material issues that require reviewTip of the day💡 Did you know, you can start a comment with 'qodo' or '@qodo' to chat about any finding |
0f7d994 to
c1cee73
Compare
|
| Filename | Overview |
|---|---|
| Generals/Code/GameEngine/Include/GameClient/GameWindowManager.h | Declares the protected modal-stack cleanup helper used by the Generals window manager. |
| Generals/Code/GameEngine/Source/GameClient/GUI/GameWindowManager.cpp | Moves modal cleanup to winDestroy and safely unlinks every stack node referencing the destroyed window. |
| GeneralsMD/Code/GameEngine/Include/GameClient/GameWindowManager.h | Declares the equivalent cleanup helper for the Zero Hour window manager. |
| GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowManager.cpp | Applies the same complete modal-stack cleanup to the Zero Hour destruction path. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[winDestroy called] --> B[Mark window destroyed]
B --> C[Remove every matching modal-stack node]
C --> D[Queue window for deferred destruction]
D --> E[processDestroyList]
E --> F[Send destroy notification]
F --> G[Delete window safely]
Reviews (1): Last reviewed commit: "bugfix(gui): Remove destroyed windows fr..." | Re-trigger Greptile
|
So is the root cause that we are destroying a window that isn't on the top of the stack? Why does that happen and can it be avoided? |
| } | ||
|
|
||
| // TheSuperHackers @bugfix arcticdolphin 27/08/2026 Remove destroyed windows from the entire modal stack. | ||
| void GameWindowManager::removeWindowFromModalStack( GameWindow *window ) |
There was a problem hiding this comment.
Just preference but this is maybe more readable:
void GameWindowManager::removeWindowFromModalStack( GameWindow *window )
{
ModalWindow *previous = nullptr;
ModalWindow *modal = m_modalHead;
while( modal )
{
ModalWindow *next = modal->next;
if( modal->window == window )
{
if( previous )
previous->next = next;
else
m_modalHead = next;
deleteInstance(modal);
}
else
{
previous = modal;
}
modal = next;
}
}
A destroyed window could stay buried in the modal stack. The game could later use that dead pointer and crash.
This removes destroyed windows from the whole stack. Hidden windows keep the old behavior so they can still be shown again.
Applied to Generals and Zero Hour.
Closes #3223