Fixed a crash on shutdown related to Editor Mode changes.

#rnx
#Jira UE-93562
#rb lauren.barnes rex.hill

#ROBOMERGE-OWNER: ryan.gerleve
#ROBOMERGE-AUTHOR: brooke.hubert
#ROBOMERGE-SOURCE: CL 13647851 via CL 13647853 via CL 13647859 via CL 13647868
#ROBOMERGE-BOT: NETWORKING (Main -> Dev-Networking) (v707-13641620)

[CL 13648305 by brooke hubert in Dev-Networking branch]
This commit is contained in:
brooke hubert
2020-06-08 18:46:40 -04:00
parent 1591f16d1c
commit 770981918a
3 changed files with 20 additions and 6 deletions

View File

@@ -76,17 +76,26 @@ FEditorModeTools::FEditorModeTools()
{
// Register our callback for undo/redo
GEditor->RegisterForUndo(this);
// This binding ensures the mode is destroyed if the type is unregistered outside of normal shutdown process
GEditor->GetEditorSubsystem<UAssetEditorSubsystem>()->OnEditorModeUnregistered().AddRaw(this, &FEditorModeTools::OnModeUnregistered);
}
}
FEditorModeTools::~FEditorModeTools()
{
// Should we call Exit on any modes that are still active, or is it too late?
if (GEditor)
{
GEditor->UnregisterForUndo(this);
GEditor->GetEditorSubsystem<UAssetEditorSubsystem>()->OnEditorModeUnregistered().RemoveAll(this);
}
DeactivateAllModes();
RecycledScriptableModes.Empty();
USelection::SelectionChangedEvent.RemoveAll(this);
USelection::SelectNoneEvent.RemoveAll(this);
USelection::SelectObjectEvent.RemoveAll(this);
GEditor->UnregisterForUndo(this);
}
void FEditorModeTools::LoadConfig(void)
@@ -579,6 +588,11 @@ void FEditorModeTools::DeactivateScriptableModeAtIndex(int32 InIndex)
ActiveScriptableModes.RemoveAt(InIndex);
}
void FEditorModeTools::OnModeUnregistered(FEditorModeID ModeID)
{
DestroyMode(ModeID);
}
void FEditorModeTools::RebuildModeToolBar()
{
// If the tab or box is not valid the toolbar has not been opened or has been closed by the user

View File

@@ -146,9 +146,6 @@ TSharedPtr<FEdMode> FEditorModeRegistry::CreateMode(FEditorModeID ModeID, FEdito
Instance->Info = (*ModeFactory)->GetModeInfo();
Instance->Owner = &Owner;
// This binding ensures the mode is destroyed if the type is unregistered
GEditor->GetEditorSubsystem<UAssetEditorSubsystem>()->OnEditorModeUnregistered().AddSP(Instance, &FEdMode::OnModeUnregistered);
Instance->Initialize();
return Instance;

View File

@@ -106,6 +106,9 @@ public:
protected:
/** Deactivates the editor mode at the specified index */
void DeactivateScriptableModeAtIndex(int32 InIndex);
/** Removes the mode ID from the tools manager when a mode is unregistered */
void OnModeUnregistered(FEditorModeID ModeID);
private:
void RebuildModeToolBar();