Sun, 20 Jul 2025 14:04:19 +0200
implement ui_app_exit_on_shutdown for Motif, Qt, Cocoa
| ui/cocoa/toolkit.m | file | annotate | diff | comparison | revisions | |
| ui/common/properties.c | file | annotate | diff | comparison | revisions | |
| ui/gtk/toolkit.c | file | annotate | diff | comparison | revisions | |
| ui/motif/toolkit.c | file | annotate | diff | comparison | revisions | |
| ui/qt/toolkit.cpp | file | annotate | diff | comparison | revisions | |
| ui/ui/toolkit.h | file | annotate | diff | comparison | revisions |
--- a/ui/cocoa/toolkit.m Sun Jul 20 12:27:33 2025 +0200 +++ b/ui/cocoa/toolkit.m Sun Jul 20 14:04:19 2025 +0200 @@ -46,9 +46,11 @@ static ui_callback startup_func; static void *startup_data; static ui_callback open_func; -void *open_data; +static void *open_data; static ui_callback exit_func; -void *exit_data; +static void *exit_data; + +static UiBool exit_on_shutdown; /* ------------------- App Init / Event Loop functions ------------------- */ @@ -89,6 +91,10 @@ exit_data = userdata; } +void ui_app_exit_on_shutdown(UiBool exitapp) { + exit_on_shutdown = exitapp; +} + void ui_cocoa_onstartup(void) { UiEvent e; e.obj = NULL; @@ -127,6 +133,9 @@ void ui_main(void) { NSApplicationMain(app_argc, app_argv); + if(exit_on_shutdown) { + exit(0); + } } /* ------------------- Window Visibility functions ------------------- */
--- a/ui/common/properties.c Sun Jul 20 12:27:33 2025 +0200 +++ b/ui/common/properties.c Sun Jul 20 14:04:19 2025 +0200 @@ -191,6 +191,11 @@ return ret; } +// public +int ui_app_save_settings(void) { + return uic_store_app_properties(); +} + const char* ui_get_property(const char *name) { return cxMapGet(application_properties, name);
--- a/ui/gtk/toolkit.c Sun Jul 20 12:27:33 2025 +0200 +++ b/ui/gtk/toolkit.c Sun Jul 20 14:04:19 2025 +0200 @@ -112,10 +112,6 @@ exit_data = userdata; } -void ui_app_onexit(void) { - uic_store_app_properties(); -} - void ui_app_exit_on_shutdown(UiBool exitapp) { exit_on_shutdown = exitapp; } @@ -135,7 +131,7 @@ if(exit_func) { exit_func(NULL, exit_data); } - ui_app_onexit(); + ui_app_save_settings(); } #endif @@ -161,7 +157,7 @@ if(exit_func) { exit_func(NULL, exit_data); } - ui_app_onexit(); + ui_app_save_settings(); #endif if(exit_on_shutdown) { exit(0);
--- a/ui/motif/toolkit.c Sun Jul 20 12:27:33 2025 +0200 +++ b/ui/motif/toolkit.c Sun Jul 20 14:04:19 2025 +0200 @@ -52,17 +52,18 @@ static ui_callback startup_func; static void *startup_data; static ui_callback open_func; -void *open_data; +static void *open_data; static ui_callback exit_func; -void *exit_data; +static void *exit_data; static ui_callback appclose_fnc; static void *appclose_udata; static int is_toplevel_realized = 0; -int event_pipe[2]; +static int event_pipe[2]; +static UiBool exit_on_shutdown; static String fallback[] = { //"*fontList: -dt-interface system-medium-r-normal-s*utf*:", @@ -139,6 +140,10 @@ exit_data = userdata; } +void ui_app_exit_on_shutdown(UiBool exitapp) { + exit_on_shutdown = exitapp; +} + void ui_main() { if(startup_func) { startup_func(NULL, startup_data); @@ -148,6 +153,9 @@ exit_func(NULL, exit_data); } uic_store_app_properties(); + if(exit_on_shutdown) { + exit(0); + } } void ui_exit_mainloop() {
--- a/ui/qt/toolkit.cpp Sun Jul 20 12:27:33 2025 +0200 +++ b/ui/qt/toolkit.cpp Sun Jul 20 14:04:19 2025 +0200 @@ -43,15 +43,17 @@ static ui_callback startup_func; static void *startup_data; static ui_callback open_func; -void *open_data; +static void *open_data; static ui_callback exit_func; -void *exit_data; +static void *exit_data; static int is_toplevel_realized = 0; -int app_argc; -char **app_argv; -QApplication *application = NULL; +static int app_argc; +static char **app_argv; +static QApplication *application = NULL; + +static UiBool exit_on_shutdown; void ui_init(const char *appname, int argc, char **argv) { application_name = appname; @@ -87,6 +89,10 @@ exit_data = userdata; } +void ui_app_exit_on_shutdown(UiBool exitapp) { + exit_on_shutdown = exitapp; +} + void ui_main() { if(startup_func) { startup_func(NULL, startup_data); @@ -98,6 +104,10 @@ uic_store_app_properties(); delete application; + + if(exit_on_shutdown) { + exit(0); + } } void ui_show(UiObject *obj) {
--- a/ui/ui/toolkit.h Sun Jul 20 12:27:33 2025 +0200 +++ b/ui/ui/toolkit.h Sun Jul 20 14:04:19 2025 +0200 @@ -514,7 +514,7 @@ UIEXPORT void ui_onopen(ui_callback f, void *userdata); UIEXPORT void ui_onexit(ui_callback f, void *userdata); -UIEXPORT void ui_app_onexit(void); +UIEXPORT int ui_app_save_settings(void); UIEXPORT void ui_app_exit_on_shutdown(UiBool exitapp); UIEXPORT void ui_main(void);