mirror of
https://github.com/edu4rdshl/gnome-shell.git
synced 2026-07-17 23:24:51 +00:00
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>
(cherry picked from commit 3e7027821d)
This commit is contained in:
parent
adc9f459c2
commit
3acab65968
1 changed files with 5 additions and 5 deletions
|
|
@ -1371,7 +1371,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;
|
||||
|
|
@ -1381,15 +1381,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);
|
||||
|
|
@ -1418,7 +1418,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…
Add table
Add a link
Reference in a new issue