close dangling group instances when the last group containing them is closed

This commit is contained in:
Lera Elvoé 2023-12-12 19:53:29 +03:00
parent 0027ca5d1a
commit a421535f11
No known key found for this signature in database

View file

@ -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)