Skip to content

Commit

Permalink
Fix #4502: Rare crash during shutdown when switching GroupDialog tabs
Browse files Browse the repository at this point in the history
Don't use wxWindow::RemoveChild(), instead just call the delete operator
on the window to be destroyed; it will automatically remove itself from
its parent.
  • Loading branch information
codereader committed Apr 1, 2017
1 parent 2f6141f commit 6209bf0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 16 deletions.
10 changes: 4 additions & 6 deletions radiant/ui/mainframe/EmbeddedLayout.cpp
Expand Up @@ -118,7 +118,7 @@ void EmbeddedLayout::deactivate()
GlobalXYWndManager().destroyViews();

// Delete the CamWnd
_camWnd = CamWndPtr();
_camWnd.reset();

// Give the notebook back to the GroupDialog
GlobalGroupDialog().reparentNotebookToSelf();
Expand All @@ -132,13 +132,11 @@ void EmbeddedLayout::deactivate()
_posHPane.disconnect();
_posGroupCamPane.disconnect();

wxFrame* topLevelParent = GlobalMainFrame().getWxTopLevelWindow();
topLevelParent->RemoveChild(_horizPane);
_horizPane->Destroy();
delete _horizPane;

// Those two have been deleted by the above, so NULL the references
_horizPane = NULL;
_groupCamPane = NULL;
_horizPane = nullptr;
_groupCamPane = nullptr;
}

void EmbeddedLayout::maximiseCameraSize()
Expand Down
10 changes: 4 additions & 6 deletions radiant/ui/mainframe/RegularLayout.cpp
Expand Up @@ -121,17 +121,15 @@ void RegularLayout::deactivate()
GlobalXYWndManager().destroyViews();

// Delete the CamWnd
_camWnd = CamWndPtr();
_camWnd.reset();

// Hide the group dialog
GlobalGroupDialog().hideDialogWindow();

wxFrame* topLevelParent = GlobalMainFrame().getWxTopLevelWindow();
topLevelParent->RemoveChild(_regular.horizPane);
_regular.horizPane->Destroy();
delete _regular.horizPane;

_regular.horizPane = NULL;
_regular.texCamPane = NULL;
_regular.horizPane = nullptr;
_regular.texCamPane = nullptr;
}

void RegularLayout::maximiseCameraSize()
Expand Down
6 changes: 2 additions & 4 deletions radiant/ui/mainframe/SplitPaneLayout.cpp
Expand Up @@ -205,7 +205,7 @@ void SplitPaneLayout::deconstructLayout()
GlobalXYWndManager().destroyViews();

// Delete the CamWnd
_camWnd = CamWndPtr();
_camWnd.reset();

// Hide the group dialog
GlobalGroupDialog().hideDialogWindow();
Expand All @@ -214,9 +214,7 @@ void SplitPaneLayout::deconstructLayout()
GlobalGroupDialog().removePage("textures");

// Destroy the widgets, so it gets removed from the main container
wxFrame* topLevelParent = GlobalMainFrame().getWxTopLevelWindow();
topLevelParent->RemoveChild(_splitPane.horizPane);
_splitPane.horizPane->Destroy();
delete _splitPane.horizPane;

_splitPane.clear();
}
Expand Down

0 comments on commit 6209bf0

Please sign in to comment.