Skip to content

Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.

fix(gameclient): stop re-initializing menus while the shell is destroyed

Olcay Seygan01a53cea4d04
diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/Shell.h b/GeneralsMD/Code/GameEngine/Include/GameClient/Shell.h
index ac874dfa7..cba555e5b 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameClient/Shell.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/Shell.h
@@ -159,6 +159,8 @@ public:
protected:
+ void destroyScreenStack( void ); ///< tear the whole stack down without re-initializing what it uncovers
+
void linkScreen( WindowLayout *screen ); ///< link screen to list
void unlinkScreen( WindowLayout *screen ); ///< remove screen from list
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Shell/Shell.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Shell/Shell.cpp
index 87ba59af4..009c183e7 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Shell/Shell.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Shell/Shell.cpp
@@ -87,12 +87,7 @@ Shell::Shell( void )
//-------------------------------------------------------------------------------------------------
Shell::~Shell( void )
{
- WindowLayout *newTop = top();
- while(newTop)
- {
- popImmediate();
- newTop = top();
- }
+ destroyScreenStack();
if(m_background)
{
@@ -138,6 +133,38 @@ Shell::~Shell( void )
} // end ~Shell
+//-------------------------------------------------------------------------------------------------
+/** Tear every screen off the stack. This is not a run of popImmediate(): that goes through
+ * doPop(), which runs the init of whatever the pop uncovers - so emptying the stack one screen
+ * at a time re-initialized every menu underneath the top one, in a shell that is being destroyed,
+ * against subsystems that are already going away. Here the screen is shut down, unlinked and
+ * deleted, and nothing underneath it is woken up. */
+//-------------------------------------------------------------------------------------------------
+void Shell::destroyScreenStack( void )
+{
+ WindowLayout *screen = top();
+ while( screen )
+ {
+
+ // do NOT set a pending pop, the screen is removed here and not by shutdownComplete()
+ m_pendingPop = FALSE;
+
+ Bool immediatePop = TRUE;
+ screen->runShutdown( &immediatePop );
+
+ unlinkScreen( screen );
+ screen->destroyWindows();
+ screen->deleteInstance();
+
+ screen = top();
+
+ } // end while
+
+ if (TheIMEManager)
+ TheIMEManager->detatch();
+
+} // end destroyScreenStack
+
//-------------------------------------------------------------------------------------------------
/** Initialize the shell system */
//-------------------------------------------------------------------------------------------------