From 96a921f4d5ee7ada3cc88b2cfe2ac0ca7ec84e61 Mon Sep 17 00:00:00 2001 From: Alx Sa Date: Wed, 5 Nov 2025 05:44:30 +0000 Subject: [PATCH] actions: Remove image from container after deletion Resolves #9285 In images_delete_image_cmd_callback (), we dereference images which we want to delete. This works for images created via the GUI. However, images created via PDB scripts are not automatically connected to the display if created with no layers. If you try to delete them, they will be dereferenced but will still in the ImageView dockable. This can cause a crash if you try to access the container again, since it will point to an unreferenced variable. This patch removes the image from the container first before dereferencing it, to prevent the crash. --- app/actions/images-commands.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/actions/images-commands.c b/app/actions/images-commands.c index 5252c75647..d394e31efd 100644 --- a/app/actions/images-commands.c +++ b/app/actions/images-commands.c @@ -112,6 +112,9 @@ images_delete_image_cmd_callback (GimpAction *action, if (image && gimp_container_have (container, GIMP_OBJECT (image))) { if (gimp_image_get_display_count (image) == 0) - g_object_unref (image); + { + gimp_container_remove (container, GIMP_OBJECT (image)); + g_object_unref (image); + } } }