Skip to content

Commit

Permalink
#5107: Simplify a few things. Block callbacks right from the start, s…
Browse files Browse the repository at this point in the history
…ince the resolveInheritance and applyColours methods are also triggering change signals.
  • Loading branch information
codereader committed Jun 25, 2021
1 parent 3d9251d commit 5ac8434
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 18 deletions.
24 changes: 11 additions & 13 deletions radiantcore/eclass/EClassManager.cpp
Expand Up @@ -189,6 +189,12 @@ void EClassManager::loadDefAndResolveInheritance()
{
_defsLoadingSignal.emit();

// Hold back all changed signals
for (const auto& eclass : _entityClasses)
{
eclass.second->blockChangedSignal(true);
}

parseDefFiles();
resolveInheritance();
applyColours();
Expand Down Expand Up @@ -349,7 +355,8 @@ void EClassManager::shutdownModule()

// Don't notify anyone anymore
_defsReloadedSignal.clear();
_changeNotificationQueue.clear();
_defsLoadedSignal.clear();
_defsLoadingSignal.clear();

// Clear member structures
_entityClasses.clear();
Expand Down Expand Up @@ -440,21 +447,13 @@ void EClassManager::parse(TextInputStream& inStr, const vfs::FileInfo& fileInfo,
}

// At this point, i is pointing to a valid entityclass

i->second->setParseStamp(_curParseStamp);

// Hold back the changed signal for the moment being
i->second->blockChangedSignal(true);
// Add this eclass to the queue (we'll fire the signal when we're done parsing)
_changeNotificationQueue.emplace_back(*i->second);

// Parse the contents of the eclass (excluding name)
i->second->parseFromTokens(tokeniser);

// Set the mod directory
i->second->setModName(modDir);

i->second->blockChangedSignal(false);
}
else if (blockType == "model")
{
Expand Down Expand Up @@ -515,13 +514,12 @@ void EClassManager::parseFile(const vfs::FileInfo& fileInfo)

void EClassManager::onDefLoadingCompleted()
{
for (auto& eclass : _changeNotificationQueue)
for (const auto& eclass : _entityClasses)
{
eclass.get().emitChangedSignal();
eclass.second->blockChangedSignal(false);
eclass.second->emitChangedSignal();
}

_changeNotificationQueue.clear();

_defsLoadedSignal.emit();
}

Expand Down
5 changes: 0 additions & 5 deletions radiantcore/eclass/EClassManager.h
Expand Up @@ -55,11 +55,6 @@ class EClassManager :

sigc::connection _eclassColoursChanged;

// During reparsing, we block all eclass changed signals to avoid deadlocks
// This queue will contain all the eclasses that need to send out their updates
// which will be done immediately after parsing is done
std::vector<std::reference_wrapper<EntityClass>> _changeNotificationQueue;

public:
// Constructor
EClassManager();
Expand Down

0 comments on commit 5ac8434

Please sign in to comment.