Skip to content

Commit

Permalink
Fix a crash during module destruction.
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Feb 13, 2017
1 parent 8809bbd commit e3edcb1
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions radiant/modulesystem/ModuleRegistry.cpp
Expand Up @@ -52,6 +52,14 @@ void ModuleRegistry::loadModules()
void ModuleRegistry::unloadModules()
{
_uninitialisedModules.clear();

// greebo: It's entirely possible that the clear() method will clear the
// last shared_ptr of a module. Module might still call this class' moduleExists()
// method which in turn refers to a semi-destructed ModulesMap instance.
// So, copy the contents to a temporary map before clearing it out.
ModulesMap tempMap;
tempMap.swap(_initialisedModules);

_initialisedModules.clear();

// We need to delete all pending objects before unloading modules
Expand Down

0 comments on commit e3edcb1

Please sign in to comment.