[rhythmbox] fading-image: stop trying to generate images while hidden



commit 344545b32a4fb7b1677be13bcb5c1f27eae7627f
Author: Jonathan Matthew <jonathan d14n org>
Date:   Wed Nov 27 17:41:10 2013 +1000

    fading-image: stop trying to generate images while hidden
    
    When the allocated size of the widget is so small there's no space
    for the actual image, we shouldn't try to generate one.  gdk-pixbuf
    and cairo don't like it much either.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=710493

 widgets/rb-fading-image.c |   17 ++++++++++++++---
 1 files changed, 14 insertions(+), 3 deletions(-)
---
diff --git a/widgets/rb-fading-image.c b/widgets/rb-fading-image.c
index ec73f28..ed1813e 100644
--- a/widgets/rb-fading-image.c
+++ b/widgets/rb-fading-image.c
@@ -546,6 +546,10 @@ scale_thumbnail_if_necessary (RBFadingImage *image, GdkPixbuf *pixbuf)
 
        w = gtk_widget_get_allocated_width (GTK_WIDGET (image)) - 2 * BORDER_WIDTH;
        h = gtk_widget_get_allocated_height (GTK_WIDGET (image)) - 2 * BORDER_WIDTH;
+       if (w < 1 || h < 1) {
+               return NULL;
+       }
+
        pw = gdk_pixbuf_get_width (pixbuf);
        ph = gdk_pixbuf_get_height (pixbuf);
 
@@ -644,8 +648,18 @@ composite_into_current (RBFadingImage *image)
        int width;
        int height;
 
+       if (image->priv->current_pat != NULL) {
+               cairo_pattern_destroy (image->priv->current_pat);
+       }
        width = gtk_widget_get_allocated_width (GTK_WIDGET (image)) - 2 * BORDER_WIDTH;
        height = gtk_widget_get_allocated_height (GTK_WIDGET (image)) - 2 * BORDER_WIDTH;
+       if (width < 1 || height < 1) {
+               image->priv->current_pat = NULL;
+               image->priv->current_width = 0;
+               image->priv->current_height = 0;
+               return;
+       }
+
        dest = cairo_image_surface_create (CAIRO_FORMAT_RGB24, width, height);
 
        cr = cairo_create (dest);
@@ -653,9 +667,6 @@ composite_into_current (RBFadingImage *image)
        render_next (image, cr, width, height, FALSE);
        cairo_destroy (cr);
 
-       if (image->priv->current_pat != NULL) {
-               cairo_pattern_destroy (image->priv->current_pat);
-       }
        image->priv->current_pat = cairo_pattern_create_for_surface (dest);
        image->priv->current_width = width;
        image->priv->current_height = height;


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