Skip to content

Commit

Permalink
#5662: EntityInspector needs to release any strong references to merg…
Browse files Browse the repository at this point in the history
…e actions to not crash after aboorting the merge
  • Loading branch information
codereader committed Jul 18, 2021
1 parent a00a347 commit 190209d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
12 changes: 12 additions & 0 deletions radiant/ui/einspector/EntityInspector.cpp
Expand Up @@ -153,6 +153,10 @@ void EntityInspector::construct()
_redoHandler = GlobalUndoSystem().signal_postRedo().connect(
sigc::mem_fun(this, &EntityInspector::onUndoRedoOperation));

_mapEditModeChangedHandler = GlobalMapModule().signal_editModeChanged().connect(
sigc::mem_fun(this, &EntityInspector::onMapEditModeChanged)
);

// initialise the properties
loadPropertyMap();
}
Expand All @@ -171,6 +175,13 @@ void EntityInspector::restoreSettings()
}
}

void EntityInspector::onMapEditModeChanged(IMap::EditMode mode)
{
// Clear the selection to not hold any references to merge nodes
changeSelectedEntity(scene::INodePtr(), scene::INodePtr());
requestIdleCallback();
}

// Entity::Observer implementation

void EntityInspector::onKeyInsert(const std::string& key,
Expand Down Expand Up @@ -429,6 +440,7 @@ void EntityInspector::onMainFrameShuttingDown()
_mergeActions.clear();
_conflictActions.clear();

_mapEditModeChangedHandler.disconnect();
_undoHandler.disconnect();
_redoHandler.disconnect();
_defsReloadedHandler.disconnect();
Expand Down
4 changes: 3 additions & 1 deletion radiant/ui/einspector/EntityInspector.h
Expand Up @@ -4,6 +4,7 @@

#include "ientityinspector.h"
#include "iradiant.h"
#include "imap.h"
#include "icommandsystem.h"
#include "imapmerge.h"
#include "iselection.h"
Expand Down Expand Up @@ -147,6 +148,7 @@ class EntityInspector :
sigc::connection _undoHandler;
sigc::connection _redoHandler;
sigc::connection _defsReloadedHandler;
sigc::connection _mapEditModeChangedHandler;

// Maps the key names to a possible merge action that should be displayed
std::map<std::string, scene::merge::IEntityKeyValueMergeAction::Ptr> _mergeActions;
Expand Down Expand Up @@ -240,7 +242,7 @@ class EntityInspector :

// Gets called after an undo operation
void onUndoRedoOperation();

void onMapEditModeChanged(IMap::EditMode mode);
void onDefsReloaded();

protected:
Expand Down

0 comments on commit 190209d

Please sign in to comment.