Browse Source

Fix crash when edit remote object instance after debugger stoped

geequlim 8 năm trước cách đây
mục cha
commit
29cd034e23

+ 10 - 2
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;
+			}
 		}
 	}
 

+ 4 - 0
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) {

+ 2 - 0
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);