plug-ins: get rid of various gimp_quit().

I am going to deprecate this function. We should stop just killing
plug-ins randomly when things are bugged. Instead we should still try
and return cleanly (with an error status and message).
This commit is contained in:
Jehan 2026-04-07 00:22:43 +02:00
parent b9277e094a
commit 73440b1627
5 changed files with 36 additions and 15 deletions

View file

@ -90,9 +90,10 @@ static GimpValueArray * optimize_run (GimpProcedure *procedu
GimpProcedureConfig *config,
gpointer run_data);
static GimpImage * do_optimizations (GimpRunMode run_mode,
GimpImage *image,
gboolean diff_only);
static GimpImage * do_optimizations (GimpRunMode run_mode,
GimpImage *image,
gboolean diff_only,
GError **error);
/* tag util functions*/
static gint parse_ms_tag (const gchar *str);
@ -313,6 +314,7 @@ optimize_run (GimpProcedure *procedure,
GimpValueArray *return_vals;
const gchar *name = gimp_procedure_get_name (procedure);
gboolean diff_only = FALSE;
GError *error = NULL;
gegl_init (NULL, NULL);
@ -338,11 +340,16 @@ optimize_run (GimpProcedure *procedure,
opmode = OPFOREGROUND;
}
image = do_optimizations (run_mode, image, diff_only);
image = do_optimizations (run_mode, image, diff_only, &error);
if (run_mode != GIMP_RUN_NONINTERACTIVE)
gimp_displays_flush ();
if (image == NULL)
return gimp_procedure_new_return_values (procedure,
GIMP_PDB_EXECUTION_ERROR,
error);
return_vals = gimp_procedure_new_return_values (procedure,
GIMP_PDB_SUCCESS,
NULL);
@ -481,9 +488,10 @@ compose_row (gint frame_num,
static GimpImage *
do_optimizations (GimpRunMode run_mode,
GimpImage *image,
gboolean diff_only)
do_optimizations (GimpRunMode run_mode,
GimpImage *image,
gboolean diff_only,
GError **error)
{
GimpImage *new_image;
GimpImageBaseType imagetype;
@ -760,7 +768,17 @@ do_optimizations (GimpRunMode run_mode,
/* FIXME - How do we tell if a gimp_drawable_get () fails? */
if (gimp_drawable_get_width (drawable) == 0)
{
gimp_quit ();
gimp_image_delete (new_image);
g_free (rawframe);
g_free (last_frame);
g_free (this_frame);
g_free (opti_frame);
g_free (back_frame);
g_set_error (error, GIMP_PLUG_IN_ERROR, 0,
"Drawable has size 0");
return NULL;
}
this_delay = get_frame_duration (this_frame_num);

View file

@ -1059,7 +1059,6 @@ init_frames (GimpPlay *play)
{
gimp_message (_("Memory could not be allocated to the frame container."));
gtk_widget_destroy (GTK_WIDGET (window));
gimp_quit ();
return;
}

View file

@ -460,8 +460,10 @@ load_image (GFile *file,
if (sunhdr.l_ras_maplength > (256 * 3))
{
g_message ("Map lengths greater than 256 entries are unsupported by GIMP.");
gimp_quit ();
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
"Map lengths greater than 256 entries are unsupported by GIMP.");
fclose (ifp);
return NULL;
}
/* Is there a RGB colormap ? */

View file

@ -788,8 +788,8 @@ draw_jigsaw (GObject *config,
}
else
{
g_printerr (_("draw_jigsaw: bad style\n"));
gimp_quit ();
/* This should never happen. */
g_critical (_("draw_jigsaw: bad style\n"));
}
if (! preview_mode)

View file

@ -280,9 +280,11 @@ load_image (GFile *file,
rs = read (fd, rbuf, sizeof (rbuf));
if (rs < 0)
{
perror ("read");
close (fd);
gimp_quit ();
g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
_("Error while reading '%s': %s"),
gimp_file_get_utf8_name (file), g_strerror (errno));
return NULL;
}
rr += rs;