From 309f137ae01f177147b364e3aeea032ad4042256 Mon Sep 17 00:00:00 2001 From: Jehan Date: Tue, 7 Apr 2026 20:08:48 +0200 Subject: [PATCH] libgimp: gimp_quit() is now deprecated. --- libgimp/gimp-debug.c | 2 +- libgimp/gimp.c | 43 ++++++++++++++++++++++++++------- libgimp/gimp.h | 11 ++++++--- libgimp/gimppdb.c | 2 +- libgimp/gimpplugin.c | 14 +++++------ libgimp/gimpprocedure.c | 6 ++--- libgimp/gimptilebackendplugin.c | 10 ++++---- 7 files changed, 59 insertions(+), 29 deletions(-) diff --git a/libgimp/gimp-debug.c b/libgimp/gimp-debug.c index b6f69cd37b..e93f9fffe9 100644 --- a/libgimp/gimp-debug.c +++ b/libgimp/gimp-debug.c @@ -404,7 +404,7 @@ gimp_fatal_func (const gchar *log_domain, } #endif /* ! G_OS_WIN32 */ - /* Do not end with gimp_quit(). + /* Do not end with _gimp_quit(). * We want the plug-in to continue its normal crash course, otherwise * we won't get the "Plug-in crashed" error in GIMP. */ diff --git a/libgimp/gimp.c b/libgimp/gimp.c index 74b2e3d23a..9344f65a4c 100644 --- a/libgimp/gimp.c +++ b/libgimp/gimp.c @@ -652,18 +652,20 @@ gimp_get_pdb (void) * * Forcefully causes the GIMP library to exit and close down its * connection to main gimp application. This function never returns. + * + * It is highly unadvised to use this function since the plug-in will + * not properly return. If you need to return from a plug-in in error, + * gracefully return with [method@Procedure.new_return_values] setting + * [enum@Gimp.PDBStatusType.EXECUTION_ERROR] as a status and with a well + * written [struct@GLib.Error] message to display. + * + * Deprecated: there are no alternatives. Quit your plug-ins cleanly + * instead. **/ void gimp_quit (void) { - gimp_close (); - -#if defined G_OS_WIN32 && defined HAVE_EXCHNDL - if (plug_in_backtrace_path) - g_free (plug_in_backtrace_path); -#endif - - exit (EXIT_SUCCESS); + _gimp_quit (); } /** @@ -1036,6 +1038,29 @@ gimp_get_progname (void) } +/* Internal functions */ + +/* _gimp_quit: + * + * Forcefully causes the GIMP library to exit and close down its + * connection to main gimp application. This function never returns. + * + * To be used internally by libgimp only. + */ +void +_gimp_quit (void) +{ + gimp_close (); + +#if defined G_OS_WIN32 && defined HAVE_EXCHNDL + if (plug_in_backtrace_path) + g_free (plug_in_backtrace_path); +#endif + + exit (EXIT_SUCCESS); +} + + /* private functions */ static void @@ -1147,7 +1172,7 @@ gimp_plugin_sigfatal_handler (gint sig_num) break; } - /* Do not end with gimp_quit(). + /* Do not end with _gimp_quit(). * We want the plug-in to continue its normal crash course, otherwise * we won't get the "Plug-in crashed" error in GIMP. */ diff --git a/libgimp/gimp.h b/libgimp/gimp.h index e9f15246a7..840b212051 100644 --- a/libgimp/gimp.h +++ b/libgimp/gimp.h @@ -176,9 +176,7 @@ GimpPlugIn * gimp_get_plug_in (void); */ GimpPDB * gimp_get_pdb (void); -/* Forcefully causes the gimp library to exit and - * close down its connection to main gimp application. - */ +GIMP_DEPRECATED void gimp_quit (void) G_GNUC_NORETURN; /* Return various constants given by the GIMP core at plug-in config time. @@ -208,6 +206,13 @@ const gchar * gimp_icon_theme_dir (void) G_GNUC_CONST; const gchar * gimp_get_progname (void) G_GNUC_CONST; +/* Forcefully causes the gimp library to exit and + * close down its connection to main gimp application. + * For internal use only. + */ +G_GNUC_INTERNAL +void _gimp_quit (void) G_GNUC_NORETURN; + G_END_DECLS #endif /* __GIMP_H__ */ diff --git a/libgimp/gimppdb.c b/libgimp/gimppdb.c index 5436b63d37..c20f025025 100644 --- a/libgimp/gimppdb.c +++ b/libgimp/gimppdb.c @@ -456,7 +456,7 @@ _gimp_pdb_run_procedure_array (GimpPDB *pdb, if (! gp_proc_run_write (_gimp_plug_in_get_write_channel (pdb->plug_in), &proc_run, pdb->plug_in)) - gimp_quit (); + _gimp_quit (); _gimp_gp_params_free (proc_run.params, proc_run.n_params, FALSE); diff --git a/libgimp/gimpplugin.c b/libgimp/gimpplugin.c index 5c57ee7498..9eaadf3edf 100644 --- a/libgimp/gimpplugin.c +++ b/libgimp/gimpplugin.c @@ -826,7 +826,7 @@ gimp_plug_in_persistent_process (GimpPlugIn *plug_in, else if (select_val == -1 && errno != EINTR) { perror ("gimp_plug_in_persistent_process"); - gimp_quit (); + _gimp_quit (); } } while (select_val == -1 && errno == EINTR); @@ -1006,7 +1006,7 @@ _gimp_plug_in_read_expect_msg (GimpPlugIn *plug_in, while (TRUE) { if (! gimp_wire_read_msg (priv->read_channel, msg, NULL)) - gimp_quit (); + _gimp_quit (); if (msg->type == type) return; /* up to the caller to call wire_destroy() */ @@ -1358,7 +1358,7 @@ gimp_plug_in_io_error_handler (GIOChannel *channel, gpointer data) { g_printerr ("%s: fatal error: GIMP crashed\n", gimp_get_progname ()); - gimp_quit (); + _gimp_quit (); /* never reached */ return TRUE; @@ -1434,7 +1434,7 @@ gimp_plug_in_single_message (GimpPlugIn *plug_in) /* Run a temp function */ if (! gimp_wire_read_msg (priv->read_channel, &msg, NULL)) - gimp_quit (); + _gimp_quit (); gimp_plug_in_process_message (plug_in, &msg); @@ -1448,7 +1448,7 @@ gimp_plug_in_process_message (GimpPlugIn *plug_in, switch (msg->type) { case GP_QUIT: - gimp_quit (); + _gimp_quit (); break; case GP_CONFIG: _gimp_config (msg->data); @@ -1500,7 +1500,7 @@ gimp_plug_in_main_proc_run (GimpPlugIn *plug_in, if (! gp_proc_return_write (priv->write_channel, &proc_return, plug_in)) - gimp_quit (); + _gimp_quit (); _gimp_gp_params_free (proc_return.params, proc_return.n_params, TRUE); } @@ -1525,7 +1525,7 @@ gimp_plug_in_temp_proc_run (GimpPlugIn *plug_in, if (! gp_temp_proc_return_write (priv->write_channel, &proc_return, plug_in)) - gimp_quit (); + _gimp_quit (); _gimp_gp_params_free (proc_return.params, proc_return.n_params, TRUE); } diff --git a/libgimp/gimpprocedure.c b/libgimp/gimpprocedure.c index 05b2de0b5c..b9f50d86f9 100644 --- a/libgimp/gimpprocedure.c +++ b/libgimp/gimpprocedure.c @@ -423,7 +423,7 @@ gimp_procedure_real_install (GimpProcedure *procedure) if (! gp_proc_install_write (_gimp_plug_in_get_write_channel (plug_in), &proc_install, plug_in)) - gimp_quit (); + _gimp_quit (); g_free (proc_install.params); g_free (proc_install.return_vals); @@ -491,7 +491,7 @@ gimp_procedure_real_uninstall (GimpProcedure *procedure) if (! gp_proc_uninstall_write (_gimp_plug_in_get_write_channel (plug_in), &proc_uninstall, plug_in)) - gimp_quit (); + _gimp_quit (); priv->installed = FALSE; } @@ -2229,7 +2229,7 @@ gimp_procedure_persistent_ready (GimpProcedure *procedure) if (! gp_extension_ack_write (_gimp_plug_in_get_write_channel (plug_in), plug_in)) - gimp_quit (); + _gimp_quit (); } /** diff --git a/libgimp/gimptilebackendplugin.c b/libgimp/gimptilebackendplugin.c index 33a3616fab..71a3ab95dc 100644 --- a/libgimp/gimptilebackendplugin.c +++ b/libgimp/gimptilebackendplugin.c @@ -349,7 +349,7 @@ gimp_tile_get (GimpTileBackendPlugin *backend_plugin, if (! gp_tile_req_write (_gimp_plug_in_get_write_channel (plug_in), &tile_req, plug_in)) - gimp_quit (); + _gimp_quit (); _gimp_plug_in_read_expect_msg (plug_in, &msg, GP_TILE_DATA); @@ -378,7 +378,7 @@ gimp_tile_get (GimpTileBackendPlugin *backend_plugin, priv->bpp); #endif g_printerr ("received tile info did not match computed tile info"); - gimp_quit (); + _gimp_quit (); } if (tile_data->use_shm) @@ -394,7 +394,7 @@ gimp_tile_get (GimpTileBackendPlugin *backend_plugin, if (! gp_tile_ack_write (_gimp_plug_in_get_write_channel (plug_in), plug_in)) - gimp_quit (); + _gimp_quit (); gimp_wire_destroy (&msg); } @@ -416,7 +416,7 @@ gimp_tile_put (GimpTileBackendPlugin *backend_plugin, if (! gp_tile_req_write (_gimp_plug_in_get_write_channel (plug_in), &tile_req, plug_in)) - gimp_quit (); + _gimp_quit (); _gimp_plug_in_read_expect_msg (plug_in, &msg, GP_TILE_DATA); @@ -444,7 +444,7 @@ gimp_tile_put (GimpTileBackendPlugin *backend_plugin, if (! gp_tile_data_write (_gimp_plug_in_get_write_channel (plug_in), &tile_data, plug_in)) - gimp_quit (); + _gimp_quit (); if (! tile_info->use_shm) tile_data.data = NULL;