st/texture-cache: Always close GdkPixbufLoader before disposal
As per the warning emitted when destroying without closing first GdkPixbufLoader finalized without calling gdk_pixbuf_loader_close() - this is not allowed. You must explicitly end the data stream to the loader before dropping the last reference. closing it is necessary. Create the GdkPixbufLoader after loading the file contents so that the loader is guaranteed to be closed before it is destroyed. (`gdk_pixbuf_loader_write()` closes it on failure.) Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3008>
This commit is contained in:
parent
a93465ed69
commit
3e7027821d
@ -1381,7 +1381,7 @@ load_sliced_image (GTask *result,
|
||||
GdkPixbuf *pix;
|
||||
gint width, height, y, x;
|
||||
gint scale_factor;
|
||||
GdkPixbufLoader *loader;
|
||||
GdkPixbufLoader *loader = NULL;
|
||||
GError *error = NULL;
|
||||
gchar *buffer = NULL;
|
||||
gsize length;
|
||||
@ -1391,15 +1391,15 @@ load_sliced_image (GTask *result,
|
||||
data = task_data;
|
||||
g_assert (data);
|
||||
|
||||
loader = gdk_pixbuf_loader_new ();
|
||||
g_signal_connect (loader, "size-prepared", G_CALLBACK (on_loader_size_prepared), data);
|
||||
|
||||
if (!g_file_load_contents (data->gfile, cancellable, &buffer, &length, NULL, &error))
|
||||
{
|
||||
g_warning ("Failed to open sliced image: %s", error->message);
|
||||
goto out;
|
||||
}
|
||||
|
||||
loader = gdk_pixbuf_loader_new ();
|
||||
g_signal_connect (loader, "size-prepared", G_CALLBACK (on_loader_size_prepared), data);
|
||||
|
||||
if (!gdk_pixbuf_loader_write (loader, (const guchar *) buffer, length, &error))
|
||||
{
|
||||
g_warning ("Failed to load image: %s", error->message);
|
||||
@ -1428,7 +1428,7 @@ load_sliced_image (GTask *result,
|
||||
out:
|
||||
/* We don't need the original pixbuf anymore, which is owned by the loader,
|
||||
* though the subpixbufs will hold a reference. */
|
||||
g_object_unref (loader);
|
||||
g_clear_object (&loader);
|
||||
g_free (buffer);
|
||||
g_clear_pointer (&error, g_error_free);
|
||||
g_task_return_pointer (result, res, free_glist_unref_gobjects);
|
||||
|
Loading…
x
Reference in New Issue
Block a user