diff --git a/app/app.c b/app/app.c index 056d368f90..e898b805e7 100644 --- a/app/app.c +++ b/app/app.c @@ -321,15 +321,15 @@ app_run (const gchar *full_prog_name, if (gimp->be_verbose) g_print ("EXIT: %s\n", G_STRFUNC); + while (g_main_context_pending (NULL)) + g_main_context_iteration (NULL, TRUE); + g_clear_object (&app); gimp_gegl_exit (gimp); errors_exit (); - while (g_main_context_pending (NULL)) - g_main_context_iteration (NULL, TRUE); - g_object_unref (gimp); gimp_debug_instances (); diff --git a/app/core/gimp.c b/app/core/gimp.c index bd1c21a773..bba1e86608 100644 --- a/app/core/gimp.c +++ b/app/core/gimp.c @@ -28,6 +28,8 @@ #include "core-types.h" +#include "gimpcoreapp.h" + #include "config/gimprc.h" #include "gegl/gimp-babl.h" @@ -1368,9 +1370,20 @@ gimp_exit_idle_cleanup_stray_images (Gimp *gimp) { GimpImage *image = image_iter->data; - /* TODO: localize after string freeze. */ - g_printerr ("INFO: a stray image seems to have been left around by a plug-in: \"%s\"", - gimp_image_get_display_name (image)); + /* Plug-in developers are expected to free the images they + * created, unless they add a display (while in GUI mode), in + * which case the user gets ownership of the image and it will be + * freed as any other image by the GUI. + * On the other hand, images created from command lines are very + * likely to still exist when the software exits, if it was closed + * by the --quit argument, or run without an interface. This is + * normal use case. + */ + if (! gimp_image_get_from_command_line (image) || + (! gimp->no_interface && ! gimp_core_app_get_quit (GIMP_CORE_APP (gimp->app)))) + /* TODO: localize after string freeze. */ + g_printerr ("INFO: a stray image seems to have been left around by a plug-in: \"%s\"\n", + gimp_image_get_display_name (image)); g_object_unref (image); } diff --git a/app/core/gimpimage-private.h b/app/core/gimpimage-private.h index 793f222485..01d4ab488a 100644 --- a/app/core/gimpimage-private.h +++ b/app/core/gimpimage-private.h @@ -148,6 +148,8 @@ struct _GimpImagePrivate /* Signal emission accumulator */ GimpImageFlushAccumulator flush_accum; + + gboolean from_command_line; }; #define GIMP_IMAGE_GET_PRIVATE(image) (((GimpImage *) (image))->priv) diff --git a/app/core/gimpimage.c b/app/core/gimpimage.c index c827b3851e..02a8cd817a 100644 --- a/app/core/gimpimage.c +++ b/app/core/gimpimage.c @@ -909,6 +909,8 @@ gimp_image_init (GimpImage *image) private->flush_accum.mask_changed = FALSE; private->flush_accum.floating_selection_changed = FALSE; private->flush_accum.preview_invalidated = FALSE; + + private->from_command_line = FALSE; } static void @@ -6408,3 +6410,28 @@ gimp_image_get_converting (GimpImage *image) return private->converting; } + +void +gimp_image_set_from_command_line (GimpImage *image, + gboolean from_command_line) +{ + GimpImagePrivate *private; + + g_return_if_fail (GIMP_IS_IMAGE (image)); + + private = GIMP_IMAGE_GET_PRIVATE (image); + + private->from_command_line = from_command_line; +} + +gboolean +gimp_image_get_from_command_line (GimpImage *image) +{ + GimpImagePrivate *private; + + g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE); + + private = GIMP_IMAGE_GET_PRIVATE (image); + + return private->from_command_line; +} diff --git a/app/core/gimpimage.h b/app/core/gimpimage.h index ead1b8fecd..243d0ba274 100644 --- a/app/core/gimpimage.h +++ b/app/core/gimpimage.h @@ -508,3 +508,7 @@ void gimp_image_invalidate_previews (GimpImage *image); void gimp_image_set_converting (GimpImage *image, gboolean converting); gboolean gimp_image_get_converting (GimpImage *image); + +void gimp_image_set_from_command_line (GimpImage *image, + gboolean from_command_line); +gboolean gimp_image_get_from_command_line (GimpImage *image); diff --git a/app/file/file-open.c b/app/file/file-open.c index b569b4c7af..429547d6c1 100644 --- a/app/file/file-open.c +++ b/app/file/file-open.c @@ -690,6 +690,7 @@ file_open_from_command_line (Gimp *gimp, { success = TRUE; + gimp_image_set_from_command_line (image, TRUE); g_object_set_data_full (G_OBJECT (gimp), GIMP_FILE_OPEN_LAST_FILE_KEY, g_object_ref (file), (GDestroyNotify) g_object_unref);