mirror of
https://codeberg.org/StreamGraph/StreamGraph.git
synced 2024-11-13 19:49:55 +01:00
fix close crash (#40)
closes #39 Reviewed-on: https://codeberg.org/Eroax/StreamGraph/pulls/40 Co-authored-by: Lera Elvoé <yagich@poto.cafe> Co-committed-by: Lera Elvoé <yagich@poto.cafe>
This commit is contained in:
parent
b8e65edcef
commit
49582126c4
2 changed files with 19 additions and 15 deletions
|
@ -99,7 +99,7 @@ func _ready() -> void:
|
||||||
unsaved_changes_dialog_single_deck.set_meta("tab", tab)
|
unsaved_changes_dialog_single_deck.set_meta("tab", tab)
|
||||||
unsaved_changes_dialog_single_deck.show()
|
unsaved_changes_dialog_single_deck.show()
|
||||||
return
|
return
|
||||||
close_tab(tab)
|
await close_tab(tab)
|
||||||
)
|
)
|
||||||
|
|
||||||
file_dialog.canceled.connect(disconnect_file_dialog_signals)
|
file_dialog.canceled.connect(disconnect_file_dialog_signals)
|
||||||
|
@ -161,9 +161,9 @@ func close_tab(tab: int) -> void:
|
||||||
var groups := DeckHolder.close_deck(tab_container.get_tab_metadata(tab, "id"))
|
var groups := DeckHolder.close_deck(tab_container.get_tab_metadata(tab, "id"))
|
||||||
# close tabs associated with this deck's groups
|
# close tabs associated with this deck's groups
|
||||||
for group in groups:
|
for group in groups:
|
||||||
for c_tab in range(tab_container.get_tab_count() - 1, 0, -1):
|
for c_tab in range(tab_container.get_tab_count() - 1, -1, -1):
|
||||||
if tab_container.get_tab_metadata(c_tab, "id") == group:
|
if tab_container.get_tab_metadata(c_tab, "id") == group:
|
||||||
tab_container.close_tab(tab)
|
tab_container.close_tab(c_tab)
|
||||||
await get_tree().process_frame
|
await get_tree().process_frame
|
||||||
|
|
||||||
tab_container.close_tab(tab)
|
tab_container.close_tab(tab)
|
||||||
|
@ -419,27 +419,28 @@ func _notification(what: int) -> void:
|
||||||
if range(tab_container.get_tab_count()).any(func(x: int): return tab_container.get_content(x).dirty):
|
if range(tab_container.get_tab_count()).any(func(x: int): return tab_container.get_content(x).dirty):
|
||||||
unsaved_changes_dialog.show()
|
unsaved_changes_dialog.show()
|
||||||
else:
|
else:
|
||||||
for i in tab_container.get_tab_count():
|
#for i in tab_container.get_tab_count():
|
||||||
close_tab(i)
|
#close_tab(i)
|
||||||
|
for i in range(tab_container.get_tab_count() - 1, -1, -1):
|
||||||
|
await close_tab(i)
|
||||||
|
|
||||||
get_tree().quit()
|
get_tree().quit()
|
||||||
|
|
||||||
|
|
||||||
func _on_unsaved_changes_dialog_single_deck_confirmed() -> void:
|
func _on_unsaved_changes_dialog_single_deck_confirmed() -> void:
|
||||||
save_tab(unsaved_changes_dialog_single_deck.get_meta("tab"))
|
save_tab(unsaved_changes_dialog_single_deck.get_meta("tab"))
|
||||||
close_tab(unsaved_changes_dialog_single_deck.get_meta("tab"))
|
await close_tab(unsaved_changes_dialog_single_deck.get_meta("tab"))
|
||||||
|
|
||||||
|
|
||||||
func _on_unsaved_changes_dialog_single_deck_custom_action(action: StringName) -> void:
|
func _on_unsaved_changes_dialog_single_deck_custom_action(action: StringName) -> void:
|
||||||
if action == &"force_close":
|
if action == &"force_close":
|
||||||
close_tab(unsaved_changes_dialog_single_deck.get_meta("tab"))
|
await close_tab(unsaved_changes_dialog_single_deck.get_meta("tab"))
|
||||||
unsaved_changes_dialog_single_deck.hide()
|
unsaved_changes_dialog_single_deck.hide()
|
||||||
|
|
||||||
|
|
||||||
func _on_unsaved_changes_dialog_confirmed() -> void:
|
func _on_unsaved_changes_dialog_confirmed() -> void:
|
||||||
for i in tab_container.get_tab_count():
|
for i in range(tab_container.get_tab_count() - 1, -1, -1):
|
||||||
close_tab(i)
|
await close_tab(i)
|
||||||
|
|
||||||
get_tree().quit()
|
get_tree().quit()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -98,10 +98,10 @@ func is_empty() -> bool:
|
||||||
## Closes a tab at the index [param tab].
|
## Closes a tab at the index [param tab].
|
||||||
func close_tab(tab: int) -> void:
|
func close_tab(tab: int) -> void:
|
||||||
content_container.get_child(tab).queue_free()
|
content_container.get_child(tab).queue_free()
|
||||||
|
_tab_metadata.remove_at(tab)
|
||||||
|
tab_bar.remove_tab(tab)
|
||||||
if !tab_bar.select_previous_available():
|
if !tab_bar.select_previous_available():
|
||||||
tab_bar.select_next_available()
|
tab_bar.select_next_available()
|
||||||
tab_bar.remove_tab(tab)
|
|
||||||
_tab_metadata.remove_at(tab)
|
|
||||||
tab_closed.emit(tab)
|
tab_closed.emit(tab)
|
||||||
if tab_bar.tab_count == 0:
|
if tab_bar.tab_count == 0:
|
||||||
_previous_active_tab = -1
|
_previous_active_tab = -1
|
||||||
|
@ -135,7 +135,10 @@ func set_tab_metadata(tab: int, key: String, value: Variant) -> void:
|
||||||
## Returns the metadata value set to the tab at index [param tab_idx] using [method set_tab_metadata].
|
## Returns the metadata value set to the tab at index [param tab_idx] using [method set_tab_metadata].
|
||||||
## If no metadata was previously set, returns [code]null[/code] by default.
|
## If no metadata was previously set, returns [code]null[/code] by default.
|
||||||
func get_tab_metadata(tab: int, key: String, default: Variant = null) -> Variant:
|
func get_tab_metadata(tab: int, key: String, default: Variant = null) -> Variant:
|
||||||
if _tab_metadata.size() - 1 < tab:
|
#if _tab_metadata.size() - 1 < tab:
|
||||||
return default
|
#return default
|
||||||
|
#if tab < _tab_metadata.size():
|
||||||
|
#return default
|
||||||
|
assert(tab < _tab_metadata.size())
|
||||||
var m = _tab_metadata[tab]
|
var m = _tab_metadata[tab]
|
||||||
return m.get(key, default)
|
return m.get(key, default)
|
||||||
|
|
Loading…
Reference in a new issue