diff options
Diffstat (limited to 'modules/visual_script/visual_script.cpp')
-rw-r--r-- | modules/visual_script/visual_script.cpp | 26 |
1 files changed, 8 insertions, 18 deletions
diff --git a/modules/visual_script/visual_script.cpp b/modules/visual_script/visual_script.cpp index 70f650cfd3..5036840413 100644 --- a/modules/visual_script/visual_script.cpp +++ b/modules/visual_script/visual_script.cpp @@ -928,13 +928,11 @@ ScriptInstance *VisualScript::instance_create(Object *p_this) { VisualScriptInstance *instance = memnew(VisualScriptInstance); instance->create(Ref<VisualScript>(this), p_this); - if (VisualScriptLanguage::singleton->lock) - VisualScriptLanguage::singleton->lock->lock(); - - instances[p_this] = instance; + { + MutexLock lock(VisualScriptLanguage::singleton->lock); - if (VisualScriptLanguage::singleton->lock) - VisualScriptLanguage::singleton->lock->unlock(); + instances[p_this] = instance; + } return instance; } @@ -2391,13 +2389,11 @@ VisualScriptInstance::VisualScriptInstance() { VisualScriptInstance::~VisualScriptInstance() { - if (VisualScriptLanguage::singleton->lock) - VisualScriptLanguage::singleton->lock->lock(); - - script->instances.erase(owner); + { + MutexLock lock(VisualScriptLanguage::singleton->lock); - if (VisualScriptLanguage::singleton->lock) - VisualScriptLanguage::singleton->lock->unlock(); + script->instances.erase(owner); + } for (Map<int, VisualScriptNodeInstance *>::Element *E = instances.front(); E; E = E->next()) { memdelete(E->get()); @@ -2836,9 +2832,6 @@ VisualScriptLanguage::VisualScriptLanguage() { _step = "_step"; _subcall = "_subcall"; singleton = this; -#ifndef NO_THREADS - lock = Mutex::create(); -#endif _debug_parse_err_node = -1; _debug_parse_err_file = ""; @@ -2859,9 +2852,6 @@ VisualScriptLanguage::VisualScriptLanguage() { VisualScriptLanguage::~VisualScriptLanguage() { - if (lock) - memdelete(lock); - if (_call_stack) { memdelete_arr(_call_stack); } |