Skip to content

Commit

Permalink
PackedScene: Avoid saving signal connections twice
Browse files Browse the repository at this point in the history
  • Loading branch information
cixil committed Jan 8, 2025
1 parent 2582793 commit 2a31298
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
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

0 comments on commit 2a31298

Please sign in to comment.