diff --git a/Generals/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp b/Generals/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp index 832e0535887..28d8e48b592 100644 --- a/Generals/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp +++ b/Generals/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp @@ -954,8 +954,8 @@ ControlBar::~ControlBar( void ) { m_scienceLayout->destroyWindows(); deleteInstance(m_scienceLayout); + m_scienceLayout = NULL; } - m_scienceLayout = NULL; m_genArrow = NULL; if(m_videoManager) delete m_videoManager; diff --git a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Diplomacy.cpp b/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Diplomacy.cpp index 5d768d96bf7..b5c9fdeb123 100644 --- a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Diplomacy.cpp +++ b/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Diplomacy.cpp @@ -292,8 +292,8 @@ void ResetDiplomacy( void ) theLayout->destroyWindows(); deleteInstance(theLayout); InitBuddyControls(-1); + theLayout = NULL; } - theLayout = NULL; theWindow = NULL; if (theAnimateWindowManager) delete theAnimateWindowManager; diff --git a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/DifficultySelect.cpp b/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/DifficultySelect.cpp index 55f25ef2622..b1904f58038 100644 --- a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/DifficultySelect.cpp +++ b/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/DifficultySelect.cpp @@ -258,8 +258,12 @@ WindowMsgHandledType DifficultySelectSystem( GameWindow *window, UnsignedInt msg pref.write(); //TheScriptEngine->setGlobalDifficulty(s_AIDiff); // CANNOT DO THIS! REPLAYS WILL BREAK! WindowLayout *layout = window->winGetLayout(); - layout->destroyWindows(); - deleteInstance(layout); + if (layout) + { + layout->destroyWindows(); + deleteInstance(layout); + } + setupGameStart(TheCampaignManager->getCurrentMap(), s_AIDiff); // start the game } @@ -268,8 +272,11 @@ WindowMsgHandledType DifficultySelectSystem( GameWindow *window, UnsignedInt msg TheCampaignManager->setCampaign( AsciiString::TheEmptyString ); TheWindowManager->winUnsetModal(window); WindowLayout *layout = window->winGetLayout(); - layout->destroyWindows(); - deleteInstance(layout); + if (layout) + { + layout->destroyWindows(); + deleteInstance(layout); + } } else if ( controlID == radioButtonEasyAIID ) diff --git a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/DownloadMenu.cpp b/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/DownloadMenu.cpp index f91ff792664..093eed7863a 100644 --- a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/DownloadMenu.cpp +++ b/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/DownloadMenu.cpp @@ -82,11 +82,14 @@ static void closeDownloadWindow( void ) if (!parent) return; - WindowLayout *menuLayout = parent->winGetLayout(); - menuLayout->runShutdown(); - menuLayout->destroyWindows(); - deleteInstance(menuLayout); - menuLayout = NULL; + WindowLayout *menuLayout = parent->winGetLayout(); + if (menuLayout) + { + menuLayout->runShutdown(); + menuLayout->destroyWindows(); + deleteInstance(menuLayout); + menuLayout = NULL; + } GameWindow *mainWin = TheWindowManager->winGetWindowFromId( NULL, NAMEKEY("MainMenu.wnd:MainMenuParent") ); if (mainWin) diff --git a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/LanMapSelectMenu.cpp b/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/LanMapSelectMenu.cpp index 8d7a7fcc28b..b46dcb05291 100644 --- a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/LanMapSelectMenu.cpp +++ b/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/LanMapSelectMenu.cpp @@ -344,9 +344,13 @@ WindowMsgHandledType LanMapSelectMenuSystem( GameWindow *window, UnsignedInt msg else if ( controlID == buttonBack ) { - mapSelectLayout->destroyWindows(); - deleteInstance(mapSelectLayout); - mapSelectLayout = NULL; + if (mapSelectLayout) + { + mapSelectLayout->destroyWindows(); + deleteInstance(mapSelectLayout); + mapSelectLayout = NULL; + } + // set the controls to NULL since they've been destroyed. NullifyControls(); showLANGameOptionsUnderlyingGUIElements(TRUE); @@ -390,9 +394,12 @@ WindowMsgHandledType LanMapSelectMenuSystem( GameWindow *window, UnsignedInt msg } - mapSelectLayout->destroyWindows(); - deleteInstance(mapSelectLayout); - mapSelectLayout = NULL; + if (mapSelectLayout) + { + mapSelectLayout->destroyWindows(); + deleteInstance(mapSelectLayout); + mapSelectLayout = NULL; + } // set the controls to NULL since they've been destroyed. NullifyControls(); diff --git a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/PopupCommunicator.cpp b/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/PopupCommunicator.cpp index 3a61e25ead4..90c47a2a919 100644 --- a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/PopupCommunicator.cpp +++ b/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/PopupCommunicator.cpp @@ -184,10 +184,13 @@ WindowMsgHandledType PopupCommunicatorSystem( GameWindow *window, UnsignedInt ms if( controlID == buttonOkID ) { - WindowLayout *popupCommunicatorLayout = window->winGetLayout(); - popupCommunicatorLayout->destroyWindows(); - deleteInstance(popupCommunicatorLayout); - popupCommunicatorLayout = NULL; + WindowLayout *popupCommunicatorLayout = window->winGetLayout(); + if (popupCommunicatorLayout) + { + popupCommunicatorLayout->destroyWindows(); + deleteInstance(popupCommunicatorLayout); + popupCommunicatorLayout = NULL; + } } // end if break; diff --git a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/QuitMenu.cpp b/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/QuitMenu.cpp index 0d1039e42c0..622073e176c 100644 --- a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/QuitMenu.cpp +++ b/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/QuitMenu.cpp @@ -122,14 +122,14 @@ void destroyQuitMenu() { fullQuitMenuLayout->destroyWindows(); deleteInstance(fullQuitMenuLayout); + fullQuitMenuLayout = NULL; } - fullQuitMenuLayout = NULL; if(noSaveLoadQuitMenuLayout) { noSaveLoadQuitMenuLayout->destroyWindows(); deleteInstance(noSaveLoadQuitMenuLayout); + noSaveLoadQuitMenuLayout = NULL; } - noSaveLoadQuitMenuLayout = NULL; quitMenuLayout = NULL; isVisible = FALSE; } diff --git a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ScoreScreen.cpp b/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ScoreScreen.cpp index 3bcc23aeb4f..b1ce2a51278 100644 --- a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ScoreScreen.cpp +++ b/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ScoreScreen.cpp @@ -759,9 +759,12 @@ void finishSinglePlayerInit( void ) TheInGameUI->freeMessageResources(); // - s_blankLayout->destroyWindows(); - deleteInstance(s_blankLayout); - s_blankLayout = NULL; + if (s_blankLayout) + { + s_blankLayout->destroyWindows(); + deleteInstance(s_blankLayout); + s_blankLayout = NULL; + } // set keyboard focus to main parent TheWindowManager->winSetFocus( parent ); diff --git a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/SkirmishMapSelectMenu.cpp b/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/SkirmishMapSelectMenu.cpp index d5e73704f8b..18abf1fe146 100644 --- a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/SkirmishMapSelectMenu.cpp +++ b/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/SkirmishMapSelectMenu.cpp @@ -521,9 +521,13 @@ WindowMsgHandledType SkirmishMapSelectMenuSystem( GameWindow *window, UnsignedIn { showSkirmishGameOptionsUnderlyingGUIElements(TRUE); - skirmishMapSelectLayout->destroyWindows(); - deleteInstance(skirmishMapSelectLayout); - skirmishMapSelectLayout = NULL; + if (skirmishMapSelectLayout) + { + skirmishMapSelectLayout->destroyWindows(); + deleteInstance(skirmishMapSelectLayout); + skirmishMapSelectLayout = NULL; + } + skirmishPositionStartSpots(); //TheShell->pop(); //do you need this ?? @@ -583,9 +587,12 @@ WindowMsgHandledType SkirmishMapSelectMenuSystem( GameWindow *window, UnsignedIn skirmishPositionStartSpots(); skirmishUpdateSlotList(); - skirmishMapSelectLayout->destroyWindows(); - deleteInstance(skirmishMapSelectLayout); - skirmishMapSelectLayout = NULL; + if (skirmishMapSelectLayout) + { + skirmishMapSelectLayout->destroyWindows(); + deleteInstance(skirmishMapSelectLayout); + skirmishMapSelectLayout = NULL; + } //TheShell->pop(); } // end if diff --git a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLMapSelectMenu.cpp b/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLMapSelectMenu.cpp index 0da72bf7b7e..b377abb63a2 100644 --- a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLMapSelectMenu.cpp +++ b/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLMapSelectMenu.cpp @@ -381,9 +381,13 @@ WindowMsgHandledType WOLMapSelectMenuSystem( GameWindow *window, UnsignedInt msg { showGameSpyGameOptionsUnderlyingGUIElements( TRUE ); - WOLMapSelectLayout->destroyWindows(); - deleteInstance(WOLMapSelectLayout); - WOLMapSelectLayout = NULL; + if (WOLMapSelectLayout) + { + WOLMapSelectLayout->destroyWindows(); + deleteInstance(WOLMapSelectLayout); + WOLMapSelectLayout = NULL; + } + WOLPositionStartSpots(); } // end if else if ( controlID == radioButtonSystemMapsID ) @@ -445,9 +449,12 @@ WindowMsgHandledType WOLMapSelectMenuSystem( GameWindow *window, UnsignedInt msg WOLDisplaySlotList(); WOLDisplayGameOptions(); - WOLMapSelectLayout->destroyWindows(); - deleteInstance(WOLMapSelectLayout); - WOLMapSelectLayout = NULL; + if (WOLMapSelectLayout) + { + WOLMapSelectLayout->destroyWindows(); + deleteInstance(WOLMapSelectLayout); + WOLMapSelectLayout = NULL; + } showGameSpyGameOptionsUnderlyingGUIElements( TRUE ); diff --git a/Generals/Code/GameEngine/Source/GameClient/GUI/Shell/Shell.cpp b/Generals/Code/GameEngine/Source/GameClient/GUI/Shell/Shell.cpp index 3908e7f2090..cc5e3ba3efc 100644 --- a/Generals/Code/GameEngine/Source/GameClient/GUI/Shell/Shell.cpp +++ b/Generals/Code/GameEngine/Source/GameClient/GUI/Shell/Shell.cpp @@ -629,15 +629,18 @@ void Shell::doPop( Bool impendingPush ) // there better be a top of the stack since we're popping DEBUG_ASSERTCRASH( currentTop, ("Shell: No top of stack and we want to pop!\n") ); - - // remove this screen from our list - unlinkScreen( currentTop ); - // delete all the windows in the screen - currentTop->destroyWindows(); + if (currentTop) + { + // remove this screen from our list + unlinkScreen(currentTop); + + // delete all the windows in the screen + currentTop->destroyWindows(); - // release the screen object back to the memory pool - deleteInstance(currentTop); + // release the screen object back to the memory pool + deleteInstance(currentTop); + } // run the init for the new top of the stack if present WindowLayout *newTop = top(); diff --git a/Generals/Code/GameEngine/Source/GameClient/GUI/WindowLayout.cpp b/Generals/Code/GameEngine/Source/GameClient/GUI/WindowLayout.cpp index 01613ca9950..d1cec832349 100644 --- a/Generals/Code/GameEngine/Source/GameClient/GUI/WindowLayout.cpp +++ b/Generals/Code/GameEngine/Source/GameClient/GUI/WindowLayout.cpp @@ -173,10 +173,6 @@ void WindowLayout::removeWindow( GameWindow *window ) //------------------------------------------------------------------------------------------------- void WindowLayout::destroyWindows( void ) { - if (this == NULL) - { - return; - } GameWindow *window; while( (window = getFirstWindow()) != 0 ) diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp index 4f2fd763c81..a8472cd9e62 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp @@ -977,8 +977,8 @@ ControlBar::~ControlBar( void ) { m_scienceLayout->destroyWindows(); deleteInstance(m_scienceLayout); + m_scienceLayout = NULL; } - m_scienceLayout = NULL; m_genArrow = NULL; if(m_videoManager) delete m_videoManager; diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Diplomacy.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Diplomacy.cpp index 693ffc2cf9d..5f8db643746 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Diplomacy.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Diplomacy.cpp @@ -292,8 +292,8 @@ void ResetDiplomacy( void ) theLayout->destroyWindows(); deleteInstance(theLayout); InitBuddyControls(-1); + theLayout = NULL; } - theLayout = NULL; theWindow = NULL; if (theAnimateWindowManager) delete theAnimateWindowManager; diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/DifficultySelect.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/DifficultySelect.cpp index f01c9e57d87..5fe47ec7211 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/DifficultySelect.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/DifficultySelect.cpp @@ -258,8 +258,12 @@ WindowMsgHandledType DifficultySelectSystem( GameWindow *window, UnsignedInt msg pref.write(); //TheScriptEngine->setGlobalDifficulty(s_AIDiff); // CANNOT DO THIS! REPLAYS WILL BREAK! WindowLayout *layout = window->winGetLayout(); - layout->destroyWindows(); - deleteInstance(layout); + if (layout) + { + layout->destroyWindows(); + deleteInstance(layout); + } + setupGameStart(TheCampaignManager->getCurrentMap(), s_AIDiff); // start the game } @@ -268,8 +272,11 @@ WindowMsgHandledType DifficultySelectSystem( GameWindow *window, UnsignedInt msg TheCampaignManager->setCampaign( AsciiString::TheEmptyString ); TheWindowManager->winUnsetModal(window); WindowLayout *layout = window->winGetLayout(); - layout->destroyWindows(); - deleteInstance(layout); + if (layout) + { + layout->destroyWindows(); + deleteInstance(layout); + } } else if ( controlID == radioButtonEasyAIID ) diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/DownloadMenu.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/DownloadMenu.cpp index adf2c6b298e..7c0d8df6f67 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/DownloadMenu.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/DownloadMenu.cpp @@ -82,11 +82,14 @@ static void closeDownloadWindow( void ) if (!parent) return; - WindowLayout *menuLayout = parent->winGetLayout(); - menuLayout->runShutdown(); - menuLayout->destroyWindows(); - deleteInstance(menuLayout); - menuLayout = NULL; + WindowLayout *menuLayout = parent->winGetLayout(); + if (menuLayout) + { + menuLayout->runShutdown(); + menuLayout->destroyWindows(); + deleteInstance(menuLayout); + menuLayout = NULL; + } GameWindow *mainWin = TheWindowManager->winGetWindowFromId( NULL, NAMEKEY("MainMenu.wnd:MainMenuParent") ); if (mainWin) diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/LanMapSelectMenu.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/LanMapSelectMenu.cpp index d01f4500b11..343da538036 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/LanMapSelectMenu.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/LanMapSelectMenu.cpp @@ -344,9 +344,13 @@ WindowMsgHandledType LanMapSelectMenuSystem( GameWindow *window, UnsignedInt msg else if ( controlID == buttonBack ) { - mapSelectLayout->destroyWindows(); - deleteInstance(mapSelectLayout); - mapSelectLayout = NULL; + if (mapSelectLayout) + { + mapSelectLayout->destroyWindows(); + deleteInstance(mapSelectLayout); + mapSelectLayout = NULL; + } + // set the controls to NULL since they've been destroyed. NullifyControls(); showLANGameOptionsUnderlyingGUIElements(TRUE); @@ -390,9 +394,12 @@ WindowMsgHandledType LanMapSelectMenuSystem( GameWindow *window, UnsignedInt msg } - mapSelectLayout->destroyWindows(); - deleteInstance(mapSelectLayout); - mapSelectLayout = NULL; + if (mapSelectLayout) + { + mapSelectLayout->destroyWindows(); + deleteInstance(mapSelectLayout); + mapSelectLayout = NULL; + } // set the controls to NULL since they've been destroyed. NullifyControls(); diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/PopupCommunicator.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/PopupCommunicator.cpp index c4b35951609..bd47f599d23 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/PopupCommunicator.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/PopupCommunicator.cpp @@ -184,10 +184,13 @@ WindowMsgHandledType PopupCommunicatorSystem( GameWindow *window, UnsignedInt ms if( controlID == buttonOkID ) { - WindowLayout *popupCommunicatorLayout = window->winGetLayout(); - popupCommunicatorLayout->destroyWindows(); - deleteInstance(popupCommunicatorLayout); - popupCommunicatorLayout = NULL; + WindowLayout *popupCommunicatorLayout = window->winGetLayout(); + if (popupCommunicatorLayout) + { + popupCommunicatorLayout->destroyWindows(); + deleteInstance(popupCommunicatorLayout); + popupCommunicatorLayout = NULL; + } } // end if break; diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/QuitMenu.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/QuitMenu.cpp index 2aa08a73d81..87403c40e63 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/QuitMenu.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/QuitMenu.cpp @@ -122,14 +122,14 @@ void destroyQuitMenu() { fullQuitMenuLayout->destroyWindows(); deleteInstance(fullQuitMenuLayout); + fullQuitMenuLayout = NULL; } - fullQuitMenuLayout = NULL; if(noSaveLoadQuitMenuLayout) { noSaveLoadQuitMenuLayout->destroyWindows(); deleteInstance(noSaveLoadQuitMenuLayout); + noSaveLoadQuitMenuLayout = NULL; } - noSaveLoadQuitMenuLayout = NULL; quitMenuLayout = NULL; isVisible = FALSE; } diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ScoreScreen.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ScoreScreen.cpp index 7aaa0e9ea7d..ee6199643f8 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ScoreScreen.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ScoreScreen.cpp @@ -935,9 +935,12 @@ void finishSinglePlayerInit( void ) TheInGameUI->freeMessageResources(); // - s_blankLayout->destroyWindows(); - deleteInstance(s_blankLayout); - s_blankLayout = NULL; + if (s_blankLayout) + { + s_blankLayout->destroyWindows(); + deleteInstance(s_blankLayout); + s_blankLayout = NULL; + } // set keyboard focus to main parent TheWindowManager->winSetFocus( parent ); diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/SkirmishMapSelectMenu.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/SkirmishMapSelectMenu.cpp index 6df968a474c..c4d72a12de2 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/SkirmishMapSelectMenu.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/SkirmishMapSelectMenu.cpp @@ -524,9 +524,13 @@ WindowMsgHandledType SkirmishMapSelectMenuSystem( GameWindow *window, UnsignedIn { showSkirmishGameOptionsUnderlyingGUIElements(TRUE); - skirmishMapSelectLayout->destroyWindows(); - deleteInstance(skirmishMapSelectLayout); - skirmishMapSelectLayout = NULL; + if (skirmishMapSelectLayout) + { + skirmishMapSelectLayout->destroyWindows(); + deleteInstance(skirmishMapSelectLayout); + skirmishMapSelectLayout = NULL; + } + skirmishPositionStartSpots(); //TheShell->pop(); //do you need this ?? @@ -586,9 +590,12 @@ WindowMsgHandledType SkirmishMapSelectMenuSystem( GameWindow *window, UnsignedIn skirmishPositionStartSpots(); skirmishUpdateSlotList(); - skirmishMapSelectLayout->destroyWindows(); - deleteInstance(skirmishMapSelectLayout); - skirmishMapSelectLayout = NULL; + if (skirmishMapSelectLayout) + { + skirmishMapSelectLayout->destroyWindows(); + deleteInstance(skirmishMapSelectLayout); + skirmishMapSelectLayout = NULL; + } //TheShell->pop(); } // end if diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLMapSelectMenu.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLMapSelectMenu.cpp index d823519db84..101659ca2c5 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLMapSelectMenu.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLMapSelectMenu.cpp @@ -393,9 +393,13 @@ WindowMsgHandledType WOLMapSelectMenuSystem( GameWindow *window, UnsignedInt msg { showGameSpyGameOptionsUnderlyingGUIElements( TRUE ); - WOLMapSelectLayout->destroyWindows(); - deleteInstance(WOLMapSelectLayout); - WOLMapSelectLayout = NULL; + if (WOLMapSelectLayout) + { + WOLMapSelectLayout->destroyWindows(); + deleteInstance(WOLMapSelectLayout); + WOLMapSelectLayout = NULL; + } + WOLPositionStartSpots(); } // end if else if ( controlID == radioButtonSystemMapsID ) @@ -457,9 +461,12 @@ WindowMsgHandledType WOLMapSelectMenuSystem( GameWindow *window, UnsignedInt msg WOLDisplaySlotList(); WOLDisplayGameOptions(); - WOLMapSelectLayout->destroyWindows(); - deleteInstance(WOLMapSelectLayout); - WOLMapSelectLayout = NULL; + if (WOLMapSelectLayout) + { + WOLMapSelectLayout->destroyWindows(); + deleteInstance(WOLMapSelectLayout); + WOLMapSelectLayout = NULL; + } showGameSpyGameOptionsUnderlyingGUIElements( TRUE ); diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Shell/Shell.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Shell/Shell.cpp index 743a2afb85a..ad8954ae150 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Shell/Shell.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Shell/Shell.cpp @@ -636,15 +636,18 @@ void Shell::doPop( Bool impendingPush ) // there better be a top of the stack since we're popping DEBUG_ASSERTCRASH( currentTop, ("Shell: No top of stack and we want to pop!\n") ); - - // remove this screen from our list - unlinkScreen( currentTop ); - // delete all the windows in the screen - currentTop->destroyWindows(); + if (currentTop) + { + // remove this screen from our list + unlinkScreen(currentTop); + + // delete all the windows in the screen + currentTop->destroyWindows(); - // release the screen object back to the memory pool - deleteInstance(currentTop); + // release the screen object back to the memory pool + deleteInstance(currentTop); + } // run the init for the new top of the stack if present WindowLayout *newTop = top(); diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/WindowLayout.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/WindowLayout.cpp index bd63f3d13a1..746f595b2ee 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/WindowLayout.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/WindowLayout.cpp @@ -173,10 +173,6 @@ void WindowLayout::removeWindow( GameWindow *window ) //------------------------------------------------------------------------------------------------- void WindowLayout::destroyWindows( void ) { - if (this == NULL) - { - return; - } GameWindow *window; while( (window = getFirstWindow()) != 0 )