Skip to content

Commit

Permalink
Fix preferences being unexpectedly reset by view function
Browse files Browse the repository at this point in the history
Solves #62 where `history_size` was reset to 0 affecting undo/redo.
  • Loading branch information
mhgolkar committed Mar 1, 2024
1 parent be8ce2f commit 9176927
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion scripts/core/configuration_handler.gd
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ class ConfigHandler :

func _on_preference_modifications_done(confirmed_by_user:bool) -> void:
print_debug("Preference Modification ", ("Confirmed." if confirmed_by_user else "Dismissed!"))
Main.UI.set_panel_visibility("preferences", false)
if confirmed_by_user:
# warning-ignore:return_value_discarded
save_configurations_and_confirm(TEMPORARY, null, false)
Main.UI.set_panel_visibility("preferences", false)
# saved as config file or not, confirmation has happened, so there are actions to be taken anyway:
# update/reset the view (& theme) changes
Main.UI.update_view_from_configuration(CONFIRMED)
Expand Down
2 changes: 1 addition & 1 deletion scripts/core/main_ui_management.gd
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ class UiManager :

# updates view partially or fully depending on the `configuration`
func update_view_from_configuration(configuration:Dictionary) -> void:
print_debug("View updated:", configuration)
# print_debug("View updated:", configuration)
for config in configuration:
var cfg = configuration[config]
match config:
Expand Down
3 changes: 1 addition & 2 deletions scripts/editor/panels/preferences_panel.gd
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ func register_connections() -> void:
FIELDS.app_local_dir_browse.connect("pressed", self, "prompt_local_dir_path", [], CONNECT_DEFERRED)
FIELDS.app_local_dir_reset_menu.connect("item_selected_value", self, "_on_app_local_dir_reset_menu_item_selected", [], CONNECT_DEFERRED)
FIELDS.history_size.get_line_edit().connect("text_changed", self, "preprocess_and_emit_modification_signal", ["history_size"], CONNECT_DEFERRED)
FIELDS.history_size.connect("value_changed", self, "preprocess_and_emit_modification_signal", ["history_size"], CONNECT_DEFERRED)
pass

func refresh_fields_view(preferences:Dictionary) -> void:
Expand All @@ -89,8 +90,6 @@ func preprocess_and_emit_modification_signal(value, field) -> void:
"language":
value = FIELDS.language.get_item_id(value) # Convert idx to lang_id
"history_size":
# NOTE: wee need this because spinners signal `value_changed` even on changes by code,
# so we use the `text_changed` of their inner LineEdit:
value = max(0, int(value))
# .. then signal
self.emit_signal("preference_modified", field, value)
Expand Down

0 comments on commit 9176927

Please sign in to comment.