From 29cd034e23115838eef8cffe935471fb601c6e11 Mon Sep 17 00:00:00 2001 From: geequlim Date: Sun, 3 Sep 2017 00:47:45 +0800 Subject: [PATCH] Fix crash when edit remote object instance after debugger stoped --- editor/property_editor.cpp | 12 ++++++++++-- editor/script_editor_debugger.cpp | 4 ++++ editor/script_editor_debugger.h | 2 ++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp index 9e8ddbd3cb1..6f558715776 100644 --- a/editor/property_editor.cpp +++ b/editor/property_editor.cpp @@ -43,12 +43,14 @@ #include "os/input.h" #include "os/keyboard.h" #include "pair.h" +#include "plugins/script_editor_plugin.h" #include "print_string.h" #include "scene/gui/label.h" #include "scene/main/viewport.h" #include "scene/resources/font.h" #include "scene/resources/packed_scene.h" #include "scene/scene_string_names.h" +#include "script_editor_debugger.h" void CustomPropertyEditor::_notification(int p_what) { @@ -3619,8 +3621,14 @@ void PropertyEditor::edit(Object *p_object) { obj->remove_change_receptor(this); if (obj->is_type("ScriptEditorDebuggerInspectedObject")) { - set_enable_capitalize_paths(false); - emit_signal("object_id_selected", obj->call("get_remote_object_id")); + ScriptEditorDebugger *sed = ScriptEditor::get_singleton()->get_debugger(); + if (sed->is_connected()) { + set_enable_capitalize_paths(false); + emit_signal("object_id_selected", obj->call("get_remote_object_id")); + } else { + obj = NULL; + p_object = NULL; + } } } diff --git a/editor/script_editor_debugger.cpp b/editor/script_editor_debugger.cpp index 00cf548d873..19f9b31820f 100644 --- a/editor/script_editor_debugger.cpp +++ b/editor/script_editor_debugger.cpp @@ -250,6 +250,10 @@ void ScriptEditorDebugger::debug_continue() { ppeer->put_var(msg); } +bool ScriptEditorDebugger::is_connected() const { + return connection.is_valid() && connection->is_connected(); +} + void ScriptEditorDebugger::_scene_tree_folded(Object *obj) { if (updating_scene_tree) { diff --git a/editor/script_editor_debugger.h b/editor/script_editor_debugger.h index 3315a0abe41..b2b9fc326ae 100644 --- a/editor/script_editor_debugger.h +++ b/editor/script_editor_debugger.h @@ -185,6 +185,8 @@ public: void debug_break(); void debug_continue(); + bool is_connected() const; + String get_var_value(const String &p_var) const; void set_live_debugging(bool p_enable);