summaryrefslogtreecommitdiff
path: root/gtk/gtkthemingbackground.c
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2011-12-23 22:23:40 +0100
committerBenjamin Otte <otte@redhat.com>2011-12-23 22:30:45 +0100
commitab1699510ebfd4c04b06b7d0e2886e498ef3e2c3 (patch)
tree6f194fdbefb0c45b48596128396a2b08a07c23d2 /gtk/gtkthemingbackground.c
parent396ae8f1de41423efc02abd793243514053934c8 (diff)
downloadgtk+-ab1699510ebfd4c04b06b7d0e2886e498ef3e2c3.tar.gz
themingbackground: Avoid erroring cairo context
Diffstat (limited to 'gtk/gtkthemingbackground.c')
-rw-r--r--gtk/gtkthemingbackground.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/gtk/gtkthemingbackground.c b/gtk/gtkthemingbackground.c
index 75ef3529ed..a525e18556 100644
--- a/gtk/gtkthemingbackground.c
+++ b/gtk/gtkthemingbackground.c
@@ -304,9 +304,6 @@ _gtk_theming_background_paint (GtkThemingBackground *bg,
"background-repeat", &repeat,
NULL);
- /* Fill background color first */
- cairo_fill_preserve (cr);
-
if (cairo_pattern_get_surface (bg->pattern, &surface) != CAIRO_STATUS_SUCCESS)
surface = NULL;
@@ -327,16 +324,22 @@ _gtk_theming_background_paint (GtkThemingBackground *bg,
scale_height = bg->image_rect.height;
}
- cairo_translate (cr, bg->image_rect.x, bg->image_rect.y);
- cairo_scale (cr, scale_width, scale_height);
- cairo_set_source (cr, bg->pattern);
- cairo_scale (cr, 1.0 / scale_width, 1.0 / scale_height);
- cairo_translate (cr, -bg->image_rect.x, -bg->image_rect.y);
+ if (scale_width && scale_height)
+ {
+ /* Fill background color first */
+ cairo_fill_preserve (cr);
+
+ cairo_translate (cr, bg->image_rect.x, bg->image_rect.y);
+ cairo_scale (cr, scale_width, scale_height);
+ cairo_set_source (cr, bg->pattern);
+ cairo_scale (cr, 1.0 / scale_width, 1.0 / scale_height);
+ cairo_translate (cr, -bg->image_rect.x, -bg->image_rect.y);
- g_free (repeat);
+ g_free (repeat);
- cairo_pattern_destroy (bg->pattern);
- bg->pattern = NULL;
+ cairo_pattern_destroy (bg->pattern);
+ bg->pattern = NULL;
+ }
}
cairo_fill (cr);