summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2023-02-01 07:32:53 +0100
committerRémi Verschelde <rverschelde@gmail.com>2023-02-01 07:32:53 +0100
commite8c405de4df358bd18cde5fdc3161109dee18f62 (patch)
tree52e47886abc0f1461f1fc5411d6105630735be05 /editor
parent897ee46888115d57e22174460588a4c335f511c4 (diff)
parent360c71c3f63bce8419df35b3bac358979742b8a7 (diff)
Merge pull request #72482 from KoBeWi/dubious_stuff
Prevent wrong unedit when clicking editor viewport
Diffstat (limited to 'editor')
-rw-r--r--editor/editor_node.cpp7
-rw-r--r--editor/editor_node.h1
-rw-r--r--editor/scene_tree_dock.cpp9
3 files changed, 16 insertions, 1 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 0405749147..fe62d9dda0 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -2136,6 +2136,13 @@ void EditorNode::edit_item(Object *p_object, Object *p_editing_owner) {
}
}
+void EditorNode::push_node_item(Node *p_node) {
+ if (p_node || Object::cast_to<Node>(InspectorDock::get_inspector_singleton()->get_edited_object())) {
+ // Don't push null if the currently edited object is not a Node.
+ push_item(p_node);
+ }
+}
+
void EditorNode::push_item(Object *p_object, const String &p_property, bool p_inspector_only) {
if (!p_object) {
InspectorDock::get_inspector_singleton()->edit(nullptr);
diff --git a/editor/editor_node.h b/editor/editor_node.h
index 3967f64c6b..914dab0254 100644
--- a/editor/editor_node.h
+++ b/editor/editor_node.h
@@ -798,6 +798,7 @@ public:
void push_item(Object *p_object, const String &p_property = "", bool p_inspector_only = false);
void edit_item(Object *p_object, Object *p_editing_owner);
+ void push_node_item(Node *p_node);
void hide_unused_editors(const Object *p_editing_owner = nullptr);
void select_editor_by_name(const String &p_name);
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp
index 86e77fbbbe..d8f1d92e44 100644
--- a/editor/scene_tree_dock.cpp
+++ b/editor/scene_tree_dock.cpp
@@ -1427,7 +1427,14 @@ void SceneTreeDock::_script_open_request(const Ref<Script> &p_script) {
}
void SceneTreeDock::_push_item(Object *p_object) {
- EditorNode::get_singleton()->push_item(p_object);
+ Node *node = Object::cast_to<Node>(p_object);
+ if (node || !p_object) {
+ // Assume that null object is a Node.
+ EditorNode::get_singleton()->push_node_item(node);
+ } else {
+ EditorNode::get_singleton()->push_item(p_object);
+ }
+
if (p_object == nullptr) {
EditorNode::get_singleton()->hide_unused_editors(this);
}