Skip to content

PackedScene: Avoid saving signal connections twice #100965

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion editor/export/editor_export_platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@ String EditorExportPlatform::_export_customize(const String &p_path, LocalVector
if (type == "PackedScene") { // Its a scene.
Ref<PackedScene> ps = ResourceLoader::load(p_path, "PackedScene", ResourceFormatLoader::CACHE_MODE_IGNORE);
ERR_FAIL_COND_V(ps.is_null(), p_path);
Node *node = ps->instantiate(PackedScene::GEN_EDIT_STATE_INSTANCE); // Make sure the child scene root gets the correct inheritance chain.
Node *node = ps->instantiate(PackedScene::GEN_EDIT_STATE_MAIN); // Make sure scene root gets the correct inheritance chain.
ERR_FAIL_NULL_V(node, p_path);
if (!customize_scenes_plugins.is_empty()) {
for (Ref<EditorExportPlugin> &plugin : customize_scenes_plugins) {
Expand Down
5 changes: 5 additions & 0 deletions scene/resources/packed_scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1059,6 +1059,11 @@ Error SceneState::_parse_connections(Node *p_owner, Node *p_node, HashMap<String
continue;
}

// Don't save connections that are already saved in a child scene.
if (c.flags & CONNECT_INHERITED) {
continue;
}

// only connections that originate or end into main saved scene are saved
// everything else is discarded

Expand Down
3 changes: 0 additions & 3 deletions tests/scene/test_packed_scene.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,6 @@ TEST_CASE("[PackedScene] Signals Preserved when Packing Scene") {
CHECK_EQ(state->get_connection_count(), 3);
}

/*
// FIXME: This subcase requires GH-48064 to be fixed.
SUBCASE("Signals that should not be saved") {
int subscene_flags = Object::CONNECT_PERSIST | Object::CONNECT_INHERITED;
// subscene node to itself
Expand All @@ -117,7 +115,6 @@ TEST_CASE("[PackedScene] Signals Preserved when Packing Scene") {
Ref<SceneState> state = packed_scene->get_state();
CHECK_EQ(state->get_connection_count(), 0);
}
*/

memdelete(main_scene_root);
}
Expand Down