From d4d17be574be46d9bcec9451ddc1a7eccf415ab2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lera=20Elvo=C3=A9?= Date: Fri, 14 Jun 2024 17:13:26 +0300 Subject: [PATCH] remove freed decks from container dicts on exit cleanup --- classes/deck/deck_holder.gd | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/classes/deck/deck_holder.gd b/classes/deck/deck_holder.gd index c1210cb..6b32cd2 100644 --- a/classes/deck/deck_holder.gd +++ b/classes/deck/deck_holder.gd @@ -272,25 +272,27 @@ static func close_deck(deck_id: String) -> Array: static func pre_exit_cleanup() -> void: - for deck_id: String in decks: + for deck_id: String in decks.keys(): if decks[deck_id] is Deck: var deck: Deck = decks[deck_id] print_verbose("DeckHolder: freeing deck %s, id %s" % [deck.id, deck.get_instance_id()]) deck.pre_exit_cleanup() deck.free() else: - for instance_id: String in decks[deck_id]: + for instance_id: String in (decks[deck_id] as Dictionary).keys(): var deck: Deck = decks[deck_id][instance_id] print_verbose("DeckHolder: freeing group %s::%s, id %s" % [deck_id, instance_id, deck.get_instance_id()]) deck.pre_exit_cleanup() deck.free() + decks.erase(deck_id) - for lib_id: String in lib_groups: + for lib_id: String in lib_groups.keys(): for instance_id: String in lib_groups[lib_id]: var deck: Deck = lib_groups[lib_id][instance_id] print_verbose("DeckHolder: freeing lib group %s::%s, id %s" % [lib_id, instance_id, deck.get_instance_id()]) deck.pre_exit_cleanup() deck.free() + lib_groups.erase(lib_id) static func send_event(event_name: StringName, event_data: Dictionary = {}) -> void: