Skip to content

Commit

Permalink
Fix crash at shutdown due to selection change events sent to the Enti…
Browse files Browse the repository at this point in the history
…tyList on tree model clear.
  • Loading branch information
codereader committed Mar 5, 2017
1 parent 1538cf6 commit 46ab86b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
19 changes: 19 additions & 0 deletions plugins/entitylist/EntityList.cpp
Expand Up @@ -38,6 +38,18 @@ EntityList::EntityList() :
// Connect the window position tracker
InitialiseWindowPosition(300, 800, RKEY_WINDOW_STATE);
}

EntityList::~EntityList()
{
// In OSX we might receive callbacks during shutdown, so disable any events
if (_treeView != nullptr)
{
_treeView->Disconnect(wxEVT_DATAVIEW_SELECTION_CHANGED,
wxDataViewEventHandler(EntityList::onSelection), NULL, this);
_treeView->Disconnect(wxEVT_DATAVIEW_ITEM_EXPANDED,
wxDataViewEventHandler(EntityList::onRowExpand), NULL, this);
}
}

void EntityList::populateWindow()
{
Expand Down Expand Up @@ -158,6 +170,13 @@ void EntityList::_preHide()

// De-register self from the SelectionSystem
GlobalSelectionSystem().removeObserver(this);

// Unselect everything when hiding the dialog
_callbackActive = true;

_treeView->UnselectAll();

_callbackActive = false;
}

// Pre-show callback
Expand Down
2 changes: 2 additions & 0 deletions plugins/entitylist/EntityList.h
Expand Up @@ -93,6 +93,8 @@ class EntityList :
void _preShow();

public:
~EntityList();

/** greebo: Shuts down this dialog, safely disconnects it
* from the EventManager and the SelectionSystem.
* Saves the window information to the Registry.
Expand Down

0 comments on commit 46ab86b

Please sign in to comment.