Skip to content

Commit

Permalink
#5200: Shifting workload from RadiantModule::postModuleInitialisation…
Browse files Browse the repository at this point in the history
… to other places, such that it can be moved into the core module or replaced entirely.
  • Loading branch information
codereader committed Aug 23, 2020
1 parent 874b0b2 commit 6113937
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 24 deletions.
24 changes: 1 addition & 23 deletions radiant/RadiantModule.cpp
Expand Up @@ -10,19 +10,11 @@
#include "ieventmanager.h"
#include "i18n.h"
#include "imainframe.h"
#include "ishaderclipboard.h"

#include "scene/Node.h"

#include "ui/mainframe/ScreenUpdateBlocker.h"

#include "module/StaticModule.h"

#include "ui/modelselector/ModelSelector.h"
#include "EventRateLimiter.h"

#include <wx/app.h>

namespace radiant
{

Expand Down Expand Up @@ -58,14 +50,6 @@ const std::string& RadiantModule::getName() const
const StringSet& RadiantModule::getDependencies() const
{
static StringSet _dependencies;

if (_dependencies.empty())
{
_dependencies.insert(MODULE_COMMANDSYSTEM);
_dependencies.insert(MODULE_XMLREGISTRY);
_dependencies.insert(MODULE_EVENTMANAGER);
}

return _dependencies;
}

Expand Down Expand Up @@ -94,18 +78,12 @@ void RadiantModule::postModuleInitialisation()
// Initialise the mainframe
GlobalMainFrame().construct();

// Initialise the shaderclipboard
GlobalShaderClipboard().clear();

// Broadcast the startup event
broadcastStartupEvent();

// Load the shortcuts from the registry
GlobalEventManager().loadAccelerators();

// Pre-load models
ui::ModelSelector::Populate();

// Show the top level window as late as possible
GlobalMainFrame().getWxTopLevelWindow()->Show();

Expand All @@ -115,7 +93,7 @@ void RadiantModule::postModuleInitialisation()
}

// Define the static Radiant module
module::StaticModule<RadiantModule> radiantCoreModule;
module::StaticModule<RadiantModule> radiantModule;

// Return the static Radiant module to other code within the main binary
RadiantModulePtr getGlobalRadiant()
Expand Down
6 changes: 6 additions & 0 deletions radiant/ui/UserInterfaceModule.cpp
Expand Up @@ -26,6 +26,7 @@
#include "MapCommands.h"
#include "ui/aas/AasControlDialog.h"
#include "ui/prefdialog/GameSetupDialog.h"
#include "ui/modelselector/ModelSelector.h"
#include "ui/layers/LayerOrthoContextMenuItem.h"
#include "ui/layers/LayerControlDialog.h"
#include "ui/overlay/OverlayDialog.h"
Expand Down Expand Up @@ -149,6 +150,11 @@ void UserInterfaceModule::initialiseModule(const IApplicationContext& ctx)
GlobalRadiant().signal_radiantStarted().connect(
sigc::ptr_fun(LayerControlDialog::onRadiantStartup));

// Pre-load models
module::GlobalModuleRegistry().signal_allModulesInitialised().connect(
sigc::ptr_fun(ModelSelector::Populate)
);

// Add the filter actions
GlobalOrthoContextMenu().addItem(
std::make_shared<FilterOrthoContextMenuItem>(_(SELECT_BY_FILTER_TEXT),
Expand Down
6 changes: 5 additions & 1 deletion radiantcore/modulesystem/ModuleRegistry.cpp
Expand Up @@ -48,6 +48,7 @@ void ModuleRegistry::unloadModules()

// Send out the signal that the DLLs/SOs will be unloaded
signal_modulesUnloading().emit();
signal_modulesUnloading().clear();

_loader->unloadModules();
}
Expand Down Expand Up @@ -183,7 +184,9 @@ void ModuleRegistry::loadAndInitialiseModules()
_sigModuleInitialisationProgress.emit(_("Modules initialised"), _progress);

// Fire the signal now, this will destroy the Splash dialog as well
// This event only happens once, release the listeners afterwards
_sigAllModulesInitialised.emit();
_sigAllModulesInitialised.clear();
}

void ModuleRegistry::shutdownModules()
Expand All @@ -198,8 +201,9 @@ void ModuleRegistry::shutdownModules()
pair.second->shutdownModule();
}

// Fire the signal before unloading the modules
// Fire the signal before unloading the modules, clear the listeners afterwards
_sigAllModulesUninitialised.emit();
_sigAllModulesUninitialised.clear();

// Free all the shared ptrs
unloadModules();
Expand Down
2 changes: 2 additions & 0 deletions radiantcore/selection/shaderclipboard/ShaderClipboard.cpp
Expand Up @@ -222,6 +222,8 @@ void ShaderClipboard::initialiseModule(const IApplicationContext& ctx)

_mapEventConn = GlobalMapModule().signal_mapEvent().connect(
sigc::mem_fun(this, &ShaderClipboard::onMapEvent));

clear();
}

void ShaderClipboard::shutdownModule()
Expand Down

0 comments on commit 6113937

Please sign in to comment.