app: keep image reference with weak pointer in GimpStatusBar.

Unlike the previous 2 commits, this was not making an error but was the reason
why our code was keeping the last closed GimpImage alive a bit longer than it
should. In particular, the status bar code was keeping a hard reference to the
image until the focus changed, hence preventing the object to get finalized
longer than necessary.

Now it will also be a weak reference, so the image is immediately freed when the
view is closed.
This commit is contained in:
Jehan 2024-04-16 15:45:56 +02:00
parent d888e95cfa
commit f10d9a706d
1 changed files with 5 additions and 13 deletions

View File

@ -2049,23 +2049,15 @@ gimp_statusbar_shell_set_image (GimpStatusbar *statusbar,
{
g_return_if_fail (image == NULL || GIMP_IS_IMAGE (image));
if (image != statusbar->image)
{
if (statusbar->image)
{
g_signal_handlers_disconnect_by_func (statusbar->image,
gimp_statusbar_shell_image_simulation_changed,
statusbar);
g_object_unref (statusbar->image);
}
}
if (statusbar->image)
g_signal_handlers_disconnect_by_func (statusbar->image,
gimp_statusbar_shell_image_simulation_changed,
statusbar);
statusbar->image = image;
g_set_weak_pointer (&statusbar->image, image);
if (statusbar->image)
{
g_object_ref (statusbar->image);
g_signal_connect (statusbar->image, "simulation-profile-changed",
G_CALLBACK (gimp_statusbar_shell_image_simulation_changed),
statusbar);