From a421535f111995fbdc95d487867e31c3a836bca1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lera=20Elvo=C3=A9?= Date: Tue, 12 Dec 2023 19:53:29 +0300 Subject: [PATCH] close dangling group instances when the last group containing them is closed --- classes/deck/deck_holder.gd | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/classes/deck/deck_holder.gd b/classes/deck/deck_holder.gd index 132d3eb..797b092 100644 --- a/classes/deck/deck_holder.gd +++ b/classes/deck/deck_holder.gd @@ -92,9 +92,16 @@ static func get_group_instance(group_id: String, instance_id: String) -> Deck: static func close_group_instance(group_id: String, instance_id: String) -> void: + # this is kinda dumb, but to close groups that may be dangling + # when all instances are closed, we have to get that list + # *before* we close the instance + var dangling_groups := get_deck(group_id).get_referenced_groups() + var group_instances: Dictionary = decks.get(group_id, {}) as Dictionary group_instances.erase(instance_id) if group_instances.is_empty(): + for group in dangling_groups: + close_all_group_instances(group) decks.erase(group_id)