diff options
Diffstat (limited to 'modules/visual_script')
-rw-r--r-- | modules/visual_script/visual_script.cpp | 26 | ||||
-rw-r--r-- | modules/visual_script/visual_script.h | 2 |
2 files changed, 9 insertions, 19 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); } diff --git a/modules/visual_script/visual_script.h b/modules/visual_script/visual_script.h index 08b84bce1d..0a6daba64f 100644 --- a/modules/visual_script/visual_script.h +++ b/modules/visual_script/visual_script.h @@ -530,7 +530,7 @@ public: static VisualScriptLanguage *singleton; - Mutex *lock; + Mutex lock; bool debug_break(const String &p_error, bool p_allow_continue = true); bool debug_break_parse(const String &p_file, int p_node, const String &p_error); |