diff --git a/core/ref_ptr.cpp b/core/ref_ptr.cpp index 961f143e5c8..6da73ca41a1 100644 --- a/core/ref_ptr.cpp +++ b/core/ref_ptr.cpp @@ -49,6 +49,14 @@ bool RefPtr::operator==(const RefPtr &p_other) const { return *ref == *ref_other; } +bool RefPtr::operator!=(const RefPtr &p_other) const { + + Ref *ref = reinterpret_cast *>(&data[0]); + Ref *ref_other = reinterpret_cast *>(const_cast(&p_other.data[0])); + + return *ref != *ref_other; +} + RefPtr::RefPtr(const RefPtr &p_other) { memnew_placement(&data[0], Ref); diff --git a/core/ref_ptr.h b/core/ref_ptr.h index f745ababa1e..320cf35609c 100644 --- a/core/ref_ptr.h +++ b/core/ref_ptr.h @@ -50,6 +50,7 @@ public: bool is_null() const; void operator=(const RefPtr &p_other); bool operator==(const RefPtr &p_other) const; + bool operator!=(const RefPtr &p_other) const; RID get_rid() const; void unref(); _FORCE_INLINE_ void *get_data() const { return data; } diff --git a/editor/script_editor_debugger.cpp b/editor/script_editor_debugger.cpp index ccee38422c4..c1899b2bde1 100644 --- a/editor/script_editor_debugger.cpp +++ b/editor/script_editor_debugger.cpp @@ -611,8 +611,16 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da } var = ResourceLoader::load(path); - if (pinfo.hint_string == "Script") - debugObj->set_script(var); + if (pinfo.hint_string == "Script") { + if (debugObj->get_script() != var) { + debugObj->set_script(RefPtr()); + Ref