Browse Source

Clear engine before instantiating modules and before locking in Engine::fromJson(). Fixes ParamHandles from being removed immediately after instantiated modules add them.

tags/v2.5.1
Andrew Belt 6 months ago
parent
commit
fc64b13fe8
1 changed files with 4 additions and 2 deletions
  1. +4
    -2
      src/engine/Engine.cpp

+ 4
- 2
src/engine/Engine.cpp View File

@@ -1215,7 +1215,11 @@ json_t* Engine::toJson() {




void Engine::fromJson(json_t* rootJ) { void Engine::fromJson(json_t* rootJ) {
clear();

// modules // modules
// We can't instantiate modules before clearing because some modules add ParamHandles upon construction.
// We also can't lock while instantiating modules because they call addParamHandle() which locks.
std::vector<Module*> modules; std::vector<Module*> modules;
json_t* modulesJ = json_object_get(rootJ, "modules"); json_t* modulesJ = json_object_get(rootJ, "modules");
if (!modulesJ) if (!modulesJ)
@@ -1257,8 +1261,6 @@ void Engine::fromJson(json_t* rootJ) {


std::lock_guard<SharedMutex> lock(internal->mutex); std::lock_guard<SharedMutex> lock(internal->mutex);


clear_NoLock();

// Add modules // Add modules
for (Module* module : modules) { for (Module* module : modules) {
addModule_NoLock(module); addModule_NoLock(module);


Loading…
Cancel
Save