[gthumb] image viewer: do not try do paint surfaces with invalid size
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb] image viewer: do not try do paint surfaces with invalid size
- Date: Mon, 16 Dec 2019 19:49:31 +0000 (UTC)
commit ea9415a703097f805ba227fedda908dfe72c4e90
Author: Paolo Bacchilega <paobac src gnome org>
Date: Mon Dec 16 20:44:47 2019 +0100
image viewer: do not try do 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 ca7160f6..58d346ae 100644
--- a/gthumb/gth-image-viewer.c
+++ b/gthumb/gth-image-viewer.c
@@ -2613,6 +2613,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;
@@ -2621,13 +2622,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;
@@ -2635,6 +2635,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]