Merge pull request #81737 from Mickeon/fix-connection-inherited-packed-scene

Fix internal `CONNECT_INHERITED` being saved in PackedScene & Make Local
This commit is contained in:
Rémi Verschelde 2023-10-24 10:53:37 +02:00
commit f41e07bfe6
No known key found for this signature in database
GPG Key ID: C3336907360768E1
3 changed files with 18 additions and 1 deletions

View File

@ -29,6 +29,7 @@
/**************************************************************************/
#include "scene_tree_dock.h"
#include "node_dock.h"
#include "core/config/project_settings.h"
#include "core/input/input.h"
@ -1081,6 +1082,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.
undo_redo->add_do_method(scene_tree, "update_tree");
undo_redo->add_undo_method(scene_tree, "update_tree");
undo_redo->commit_action();
@ -1479,6 +1482,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();

View File

@ -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);

View File

@ -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++) {