Skip to content

Commit

Permalink
fix repeatedly loading engine
Browse files Browse the repository at this point in the history
Signed-off-by: Ian Chen <[email protected]>
  • Loading branch information
iche033 committed Jan 19, 2024
1 parent c62f6e9 commit 674cd66
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/RenderEngineManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -378,14 +378,24 @@ RenderEngine *RenderEngineManagerPrivate::Engine(EngineInfo _info,
if (defaultIt != this->defaultEngines.end())
libName = defaultIt->second;

std::lock_guard<std::recursive_mutex> lock(this->enginesMutex);
// Check to see if we need to load the engine
auto engineIt = this->engines.find(libName);
bool loadEngine = engineIt == this->engines.end() ||
!engineIt->second;

// Load the engine plugin
if (this->LoadEnginePlugin(libName, _path))
if (loadEngine && this->LoadEnginePlugin(libName, _path))
{
std::lock_guard<std::recursive_mutex> lock(this->enginesMutex);
auto engineIt = this->engines.find(libName);
engineIt = this->engines.find(libName);
if (engineIt != this->engines.end())
engine = engineIt->second;
}
else if (engineIt->second)
{
// Engine is already loaded
engine = engineIt->second;
}
}

if (!engine)
Expand Down

0 comments on commit 674cd66

Please sign in to comment.