summaryrefslogtreecommitdiff
path: root/libgnome-desktop
diff options
context:
space:
mode:
authorCorey Berla <corey@berla.me>2023-01-17 09:08:32 -0800
committerBastien Nocera <hadess@hadess.net>2023-01-18 12:17:39 +0100
commitc4c89d573cb6440ac10adf9f1963469c92d06af7 (patch)
treefbc7d0562a6a523a7407d249c47e2d6f40dfe120 /libgnome-desktop
parent667624bf47d7f3923dde30aa5152395d9e78c9ca (diff)
downloadgnome-desktop-c4c89d573cb6440ac10adf9f1963469c92d06af7.tar.gz
thumbnail: Refactor gnome_desktop_thumbnail_factory_save_thumbnail
No functional changes. Use g_auto to simplify logic. Also, don't reuse path variable. Note that failed_path is only used inside a conditional, but will be used outside it momentarily.
Diffstat (limited to 'libgnome-desktop')
-rw-r--r--libgnome-desktop/gnome-desktop-thumbnail.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/libgnome-desktop/gnome-desktop-thumbnail.c b/libgnome-desktop/gnome-desktop-thumbnail.c
index c4ce0bb2..2ef12427 100644
--- a/libgnome-desktop/gnome-desktop-thumbnail.c
+++ b/libgnome-desktop/gnome-desktop-thumbnail.c
@@ -1379,25 +1379,25 @@ gnome_desktop_thumbnail_factory_save_thumbnail (GnomeDesktopThumbnailFactory *f
GCancellable *cancellable,
GError **error)
{
- char *path;
+ g_autofree char *path = NULL;
+ g_autofree char *failed_path = NULL;
gboolean ret;
GError *inner_error = NULL;
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
path = thumbnail_path (uri, factory->priv->size);
+ failed_path = thumbnail_failed_path (uri);
ret = save_thumbnail (thumbnail, path, uri, original_mtime, cancellable, &inner_error);
if (!ret && !g_error_matches (inner_error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
{
- thumbnail = make_failed_thumbnail ();
- g_free (path);
- path = thumbnail_failed_path (uri);
- save_thumbnail (thumbnail, path, uri, original_mtime, cancellable, NULL);
- g_object_unref (thumbnail);
+ g_autoptr (GdkPixbuf) failed_thumbnail = make_failed_thumbnail ();
+
+ save_thumbnail (failed_thumbnail, failed_path, uri, original_mtime, cancellable, NULL);
}
if (!ret)
g_propagate_error (error, inner_error);
- g_free (path);
+
return ret;
}