Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix internal CONNECT_INHERITED being saved in PackedScene & Make Local #81737

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions editor/scene_tree_dock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
/**************************************************************************/

#include "scene_tree_dock.h"
#include "node_dock.h"

#include "core/config/project_settings.h"
#include "core/input/input.h"
Expand Down Expand Up @@ -1077,6 +1078,8 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
undo_redo->add_do_method(node, "set_scene_file_path", "");
undo_redo->add_undo_method(node, "set_scene_file_path", node->get_scene_file_path());
_node_replace_owner(node, node, root);
_node_strip_signal_inheritance(node);
NodeDock::get_singleton()->set_node(node); // Refresh.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if there is better way to refresh it.

Copy link
Contributor Author

@Mickeon Mickeon Oct 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wondered too, but it didn't seem like it because all of the "refreshing" logic is inside the set_node method. It would require moving it out...

Maybe NodeDock::restore_last_valid_node would work just the same? In hindsight, I don't see why not.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's probably fine for now, but if we ever decide to add early return to set_node() it will stop working.
Though my biggest concern would be that this method is not used outside editor node, so either the dock is not refreshed by anything else or there is a better way.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was about to go with the change, but I'll keep set_node() then. The lack of an early return is unexpected though, yeah.

The NodeDock has a pretty simple bunch of methods. None of them are like restore_last_valid_node() or set_node(), so they seem like the closest thing to a refresh?

undo_redo->add_do_method(scene_tree, "update_tree");
undo_redo->add_undo_method(scene_tree, "update_tree");
undo_redo->commit_action();
Expand Down Expand Up @@ -1475,6 +1478,19 @@ void SceneTreeDock::_node_replace_owner(Node *p_base, Node *p_node, Node *p_root
}
}

void SceneTreeDock::_node_strip_signal_inheritance(Node *p_node) {
List<Object::Connection> conns;
p_node->get_all_signal_connections(&conns);

for (Object::Connection conn : conns) {
conn.signal.disconnect(conn.callable);
conn.signal.connect(conn.callable, conn.flags & ~CONNECT_INHERITED);
}
for (int i = 0; i < p_node->get_child_count(); i++) {
_node_strip_signal_inheritance(p_node->get_child(i));
}
}

void SceneTreeDock::_load_request(const String &p_path) {
EditorNode::get_singleton()->open_request(p_path);
_local_tree_selected();
Expand Down
1 change: 1 addition & 0 deletions editor/scene_tree_dock.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ class SceneTreeDock : public VBoxContainer {
};

void _node_replace_owner(Node *p_base, Node *p_node, Node *p_root, ReplaceOwnerMode p_mode = MODE_BIDI);
void _node_strip_signal_inheritance(Node *p_node);
void _load_request(const String &p_path);
void _script_open_request(const Ref<Script> &p_script);
void _push_item(Object *p_object);
Expand Down
2 changes: 1 addition & 1 deletion scene/resources/packed_scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1028,7 +1028,7 @@ Error SceneState::_parse_connections(Node *p_owner, Node *p_node, HashMap<String
cd.to = target_id;
cd.method = _nm_get_string(base_callable.get_method(), name_map);
cd.signal = _nm_get_string(c.signal.get_name(), name_map);
cd.flags = c.flags;
cd.flags = c.flags & ~CONNECT_INHERITED; // Do not store inherited.
cd.unbinds = unbinds;

for (int i = 0; i < binds.size(); i++) {
Expand Down
Loading