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)