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 unable to disconnect signal in Editor once created #69661

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
1 change: 1 addition & 0 deletions core/object/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,7 @@ class Object {
CONNECT_PERSIST = 2, // hint for scene to save this connection
CONNECT_ONE_SHOT = 4,
CONNECT_REFERENCE_COUNTED = 8,
CONNECT_INHERITED = 16, // Used in editor builds.
};

struct Connection {
Expand Down
18 changes: 1 addition & 17 deletions editor/connections_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -788,23 +788,7 @@ bool ConnectionsDock::_is_item_signal(TreeItem &p_item) {
}

bool ConnectionsDock::_is_connection_inherited(Connection &p_connection) {
Node *scene_root = EditorNode::get_singleton()->get_edited_scene();
Ref<PackedScene> scn = ResourceLoader::load(scene_root->get_scene_file_path());
ERR_FAIL_NULL_V(scn, false);

Ref<SceneState> state = scn->get_state();
ERR_FAIL_NULL_V(state, false);

Node *source = Object::cast_to<Node>(p_connection.signal.get_object());
Node *target = Object::cast_to<Node>(p_connection.callable.get_object());

const NodePath source_path = scene_root->get_path_to(source);
const NodePath target_path = scene_root->get_path_to(target);
const StringName signal_name = p_connection.signal.get_name();
const StringName method_name = p_connection.callable.get_method();

// If it cannot be found in PackedScene, this connection was inherited.
return !state->has_connection(source_path, signal_name, target_path, method_name, true);
return bool(p_connection.flags & CONNECT_INHERITED);
}

/*
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 @@ -450,7 +450,7 @@ Node *SceneState::instantiate(GenEditState p_edit_state) const {
callable = callable.bindp(argptrs, binds.size());
}

cfrom->connect(snames[c.signal], callable, CONNECT_PERSIST | c.flags);
cfrom->connect(snames[c.signal], callable, CONNECT_PERSIST | c.flags | (p_edit_state == GEN_EDIT_STATE_MAIN ? 0 : CONNECT_INHERITED));
Copy link
Member

Choose a reason for hiding this comment

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

Couldn't this possibly be useful at runtime too?

Copy link
Member

Choose a reason for hiding this comment

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

It could be useful if someone uses custom scene serialization, but it's rather corner-case.

}

//Node *s = ret_nodes[0];
Expand Down