Skip to content

Commit

Permalink
Fix issue #2 Unable to package with the plugin enabled
Browse files Browse the repository at this point in the history
When packaging a project, the Source Control Plugin is triggered, and try to register a Menu Extension.
But the LevelEditor module is unavailable at this step, which raises an assertion.

Now uses FModuleManager::GetModulePtr() and test the returned pointer instead of FModuleManager::LoadModuleChecked() that was causing the assertion.
  • Loading branch information
SRombauts committed Nov 13, 2016
1 parent 67238a6 commit fcd56f5
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions Source/PlasticSourceControl/Private/PlasticSourceControlMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,26 @@ void FPlasticSourceControlMenu::Register()

// Register the extension with the level editor
{
FLevelEditorModule::FLevelEditorMenuExtender ViewMenuExtender = FLevelEditorModule::FLevelEditorMenuExtender::CreateRaw(this, &FPlasticSourceControlMenu::OnExtendLevelEditorViewMenu);
FLevelEditorModule& LevelEditorModule = FModuleManager::LoadModuleChecked<FLevelEditorModule>("LevelEditor");
auto& MenuExtenders = LevelEditorModule.GetAllLevelEditorToolbarSourceControlMenuExtenders();
MenuExtenders.Add(ViewMenuExtender);
ViewMenuExtenderHandle = MenuExtenders.Last().GetHandle();
FLevelEditorModule* LevelEditorModule = FModuleManager::GetModulePtr<FLevelEditorModule>("LevelEditor");
if (LevelEditorModule)
{
FLevelEditorModule::FLevelEditorMenuExtender ViewMenuExtender = FLevelEditorModule::FLevelEditorMenuExtender::CreateRaw(this, &FPlasticSourceControlMenu::OnExtendLevelEditorViewMenu);
auto& MenuExtenders = LevelEditorModule->GetAllLevelEditorToolbarSourceControlMenuExtenders();
MenuExtenders.Add(ViewMenuExtender);
ViewMenuExtenderHandle = MenuExtenders.Last().GetHandle();
}
}
}

void FPlasticSourceControlMenu::Unregister()
{
// Unregister the level editor extensions
{
FLevelEditorModule& LevelEditorModule = FModuleManager::LoadModuleChecked<FLevelEditorModule>("LevelEditor");
LevelEditorModule.GetAllLevelEditorToolbarSourceControlMenuExtenders().RemoveAll([=](const FLevelEditorModule::FLevelEditorMenuExtender& Extender) { return Extender.GetHandle() == ViewMenuExtenderHandle; });
FLevelEditorModule* LevelEditorModule = FModuleManager::GetModulePtr<FLevelEditorModule>("LevelEditor");
if (LevelEditorModule)
{
LevelEditorModule->GetAllLevelEditorToolbarSourceControlMenuExtenders().RemoveAll([=](const FLevelEditorModule::FLevelEditorMenuExtender& Extender) { return Extender.GetHandle() == ViewMenuExtenderHandle; });
}
}

// This function may be called during shutdown to clean up your module. For modules that support dynamic reloading,
Expand Down

0 comments on commit fcd56f5

Please sign in to comment.