[gnome-software/1256-remote-flatpak-icons-do-not-seem-to-be-fetched-anymore] gs-remote-icon: Set icon dimensions when already downloaded



commit d1fcba35186e6d1a1c215c5f143a2e99580d57e3
Author: Milan Crha <mcrha redhat com>
Date:   Wed May 19 18:06:02 2021 +0200

    gs-remote-icon: Set icon dimensions when already downloaded
    
    The code expects to have set icon dimensions to know whether it's usable,
    but the remote icon sets it only if it downloads the icon. When it's already
    downloaded the remote icon didn't set the dimensions, which resulted
    in the icon not being considered as a usable icon.
    
    Closes https://gitlab.gnome.org/GNOME/gnome-software/-/issues/1256

 lib/gs-remote-icon.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
---
diff --git a/lib/gs-remote-icon.c b/lib/gs-remote-icon.c
index e8455911a..061863333 100644
--- a/lib/gs-remote-icon.c
+++ b/lib/gs-remote-icon.c
@@ -339,8 +339,16 @@ gs_remote_icon_ensure_cached (GsRemoteIcon  *self,
                return FALSE;
 
        /* Already in cache? */
-       if (g_file_test (cache_filename, G_FILE_TEST_IS_REGULAR))
+       if (g_file_test (cache_filename, G_FILE_TEST_IS_REGULAR)) {
+               gint width = 0, height = 0;
+               /* Ensure the downloaded image dimensions are stored on the icon */
+               if (!g_object_get_data (G_OBJECT (self), "width") &&
+                   gdk_pixbuf_get_file_info (cache_filename, &width, &height)) {
+                       g_object_set_data (G_OBJECT (self), "width", GINT_TO_POINTER (width));
+                       g_object_set_data (G_OBJECT (self), "height", GINT_TO_POINTER (height));
+               }
                return TRUE;
+       }
 
        cached_pixbuf = gs_icon_download (soup_session, uri, cache_filename, maximum_icon_size, cancellable, 
error);
        if (cached_pixbuf == NULL)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]