# HG changeset patch # User Olaf Wintermann # Date 1730053191 -3600 # Node ID eb63af2f2bdd74d43bf3c06b126d5a45b99627b9 # Parent ee4e4742391e7e959fc46057a3fd4d5853d187fb fix crash when closing the settings window diff -r ee4e4742391e -r eb63af2f2bdd application/settings.c --- a/application/settings.c Sun Oct 27 18:24:37 2024 +0100 +++ b/application/settings.c Sun Oct 27 19:19:51 2024 +0100 @@ -86,7 +86,7 @@ ui_close(event->obj); } -void settings_cancel(UiEvent *event, void *userdata) { +void settings_close(UiEvent *event, void *userdata) { SettingsWindow *settings = event->window; if(settings->config_saved) { // function was called as context closefunc by ui_close @@ -95,9 +95,11 @@ return; } dav_config_free(settings->config); - if(userdata) { - ui_close(event->obj); - } +} + +void settings_cancel(UiEvent *event, void *userdata) { + SettingsWindow *settings = event->window; + ui_close(event->obj); } void settings_window_open() { @@ -107,7 +109,7 @@ } UiObject *obj = ui_simple_window("Settings", NULL); - ui_context_closefunc(obj->ctx, settings_cancel, NULL); + ui_context_closefunc(obj->ctx, settings_close, NULL); SettingsWindow *wdata = ui_malloc(obj->ctx, sizeof(SettingsWindow)); wdata->config = config; obj->window = wdata; @@ -246,7 +248,7 @@ } ui_hbox(obj, .fill = UI_OFF, .margin = 10) { - ui_button(obj, .label = "Cancel", .onclick = settings_cancel, .onclickdata = "close"); + ui_button(obj, .label = "Cancel", .onclick = settings_cancel); ui_label(obj, .fill = UI_ON); ui_button(obj, .label = "Save", .onclick = settings_ok); }