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.
This commit is contained in:
Alx Sa 2025-11-05 05:44:30 +00:00
parent b5c79ebf94
commit 96a921f4d5

View file

@ -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)
{
gimp_container_remove (container, GIMP_OBJECT (image));
g_object_unref (image);
}
}
}