[gthumb/gthumb-3-8] image viewer: do not try to paint surfaces with invalid size
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb/gthumb-3-8] image viewer: do not try to paint surfaces with invalid size
- Date: Mon, 16 Dec 2019 20:29:27 +0000 (UTC)
commit a9ce1e9329ea5cf73d41bb9822c47ac5d5b054ba
Author: Paolo Bacchilega <paobac src gnome org>
Date: Mon Dec 16 21:25:27 2019 +0100
image viewer: do not try to paint surfaces with invalid size
gthumb/gth-image-viewer.c | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
---
diff --git a/gthumb/gth-image-viewer.c b/gthumb/gth-image-viewer.c
index fc0e022a..d547ad3c 100644
--- a/gthumb/gth-image-viewer.c
+++ b/gthumb/gth-image-viewer.c
@@ -2580,6 +2580,7 @@ gth_image_viewer_paint (GthImageViewer *self,
cairo_filter_t filter)
{
int original_width;
+ int surface_width;
double zoom_level;
double src_dx;
double src_dy;
@@ -2588,13 +2589,12 @@ gth_image_viewer_paint (GthImageViewer *self,
double dwidth;
double dheight;
- cairo_save (cr);
-
- cairo_rectangle (cr, 0, 0, self->visible_area.width, self->visible_area.height);
- cairo_clip (cr);
+ surface_width = cairo_image_surface_get_width (surface);
+ if (surface_width <= 0)
+ return;
gth_image_viewer_get_original_size (self, &original_width, NULL);
- zoom_level = self->priv->zoom_level * ((double) original_width / cairo_image_surface_get_width
(surface));
+ zoom_level = self->priv->zoom_level * ((double) original_width / surface_width);
src_dx = (double) src_x / zoom_level;
src_dy = (double) src_y / zoom_level;
dest_dx = (double) dest_x / zoom_level;
@@ -2602,6 +2602,13 @@ gth_image_viewer_paint (GthImageViewer *self,
dwidth = (double) width / zoom_level;
dheight = (double) height / zoom_level;
+ if ((dwidth < 1) || (dheight < 1))
+ return;
+
+ cairo_save (cr);
+
+ cairo_rectangle (cr, 0, 0, self->visible_area.width, self->visible_area.height);
+ cairo_clip (cr);
cairo_scale (cr, zoom_level, zoom_level);
cairo_set_source_surface (cr, surface, dest_dx - src_dx, dest_dy - src_dy);
cairo_pattern_set_filter (cairo_get_source (cr), filter);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]