浏览代码

Make sub-inspectors not listen to node removals, since they never edit nodes. Fixes #23554

Juan Linietsky 6 年之前
父节点
当前提交
853f985b63
共有 3 个文件被更改,包括 14 次插入12 次删除
  1. 11 9
      editor/editor_inspector.cpp
  2. 2 2
      editor/editor_inspector.h
  3. 1 1
      editor/editor_properties.cpp

+ 11 - 9
editor/editor_inspector.cpp

@@ -1899,13 +1899,13 @@ int EditorInspector::get_scroll_offset() const {
 	return get_v_scroll();
 }
 
-void EditorInspector::set_use_sub_inspector_bg(bool p_enable) {
+void EditorInspector::set_sub_inspector(bool p_enable) {
 
-	use_sub_inspector_bg = p_enable;
+	sub_inspector = p_enable;
 	if (!is_inside_tree())
 		return;
 
-	if (use_sub_inspector_bg) {
+	if (sub_inspector) {
 		add_style_override("bg", get_stylebox("sub_inspector_bg", "Editor"));
 	} else {
 		add_style_override("bg", get_stylebox("bg", "Tree"));
@@ -2126,16 +2126,18 @@ void EditorInspector::_notification(int p_what) {
 
 	if (p_what == NOTIFICATION_ENTER_TREE) {
 
-		get_tree()->connect("node_removed", this, "_node_removed");
-		if (use_sub_inspector_bg) {
+		if (sub_inspector) {
 			add_style_override("bg", get_stylebox("sub_inspector_bg", "Editor"));
-		} else if (is_inside_tree()) {
+		} else {
 			add_style_override("bg", get_stylebox("bg", "Tree"));
+			get_tree()->connect("node_removed", this, "_node_removed");
 		}
 	}
 	if (p_what == NOTIFICATION_EXIT_TREE) {
 
-		get_tree()->disconnect("node_removed", this, "_node_removed");
+		if (!sub_inspector) {
+			get_tree()->disconnect("node_removed", this, "_node_removed");
+		}
 		edit(NULL);
 	}
 
@@ -2184,7 +2186,7 @@ void EditorInspector::_notification(int p_what) {
 
 	if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {
 
-		if (use_sub_inspector_bg) {
+		if (sub_inspector) {
 			add_style_override("bg", get_stylebox("sub_inspector_bg", "Editor"));
 		} else if (is_inside_tree()) {
 			add_style_override("bg", get_stylebox("bg", "Tree"));
@@ -2280,7 +2282,7 @@ EditorInspector::EditorInspector() {
 	_prop_edited = "property_edited";
 	set_process(true);
 	property_focusable = -1;
-	use_sub_inspector_bg = false;
+	sub_inspector = false;
 
 	get_v_scrollbar()->connect("value_changed", this, "_vscroll_changed");
 	update_scroll_request = -1;

+ 2 - 2
editor/editor_inspector.h

@@ -281,7 +281,7 @@ class EditorInspector : public ScrollContainer {
 	bool update_all_pending;
 	bool read_only;
 	bool keying;
-	bool use_sub_inspector_bg;
+	bool sub_inspector;
 
 	float refresh_countdown;
 	bool update_tree_pending;
@@ -375,7 +375,7 @@ public:
 	void set_object_class(const String &p_class);
 	String get_object_class() const;
 
-	void set_use_sub_inspector_bg(bool p_enable);
+	void set_sub_inspector(bool p_enable);
 
 	EditorInspector();
 };

+ 1 - 1
editor/editor_properties.cpp

@@ -2448,7 +2448,7 @@ void EditorPropertyResource::update_property() {
 				sub_inspector->set_enable_v_scroll(false);
 				sub_inspector->set_use_doc_hints(true);
 
-				sub_inspector->set_use_sub_inspector_bg(true);
+				sub_inspector->set_sub_inspector(true);
 				sub_inspector->set_enable_capitalize_paths(true);
 
 				sub_inspector->connect("property_keyed", this, "_sub_inspector_property_keyed");