diff --git a/ChangeLog b/ChangeLog index 37d594a8ec..b3d8b17370 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2003-04-05 Sven Neumann + + * app/display/gimpdisplayshell-selection.c: applied a patch from + Pedro Gimeno that fixes incorrect drawing of the selection border + caused by overflowing 16bit X coordinates (bug #110014). + 2003-04-04 Sven Neumann * themes/Default/images/Makefile.am diff --git a/app/display/gimpdisplayshell-selection.c b/app/display/gimpdisplayshell-selection.c index 8c5adcc170..6bbeab25d5 100644 --- a/app/display/gimpdisplayshell-selection.c +++ b/app/display/gimpdisplayshell-selection.c @@ -486,10 +486,14 @@ selection_render_points (Selection *select) gint dx, dy; gint dxa, dya; gint r; + gint xsize, ysize; + gint x2, y2; if (select->segs_in == NULL) return; + g_return_if_fail (select->shell != NULL); + for (j = 0; j < 8; j++) { max_npoints[j] = MAX_POINTS_INC; @@ -497,6 +501,9 @@ selection_render_points (Selection *select) select->num_points_in[j] = 0; } + xsize = select->shell->disp_width; + ysize = select->shell->disp_height; + for (i = 0; i < select->num_segs_in; i++) { #ifdef VERBOSE @@ -506,8 +513,9 @@ selection_render_points (Selection *select) select->segs_in[i].x2, select->segs_in[i].y2); #endif - x = select->segs_in[i].x1; - dxa = select->segs_in[i].x2 - x; + x = CLAMP (select->segs_in[i].x1, -1, xsize); + x2 = CLAMP (select->segs_in[i].x2, -1, xsize); + dxa = x2 - x; if (dxa > 0) { dx = 1; @@ -517,8 +525,9 @@ selection_render_points (Selection *select) dxa = -dxa; dx = -1; } - y = select->segs_in[i].y1; - dya = select->segs_in[i].y2 - y; + y = CLAMP (select->segs_in[i].y1, -1, ysize); + y2 = CLAMP (select->segs_in[i].y2, -1, ysize); + dya = y2 - y; if (dya > 0) { dy = 1; @@ -542,7 +551,7 @@ selection_render_points (Selection *select) y += dy; r -= (dxa << 1); } - } while (x != select->segs_in[i].x2); + } while (x != x2); } else if (dxa < dya) { @@ -558,7 +567,7 @@ selection_render_points (Selection *select) x += dx; r -= (dya << 1); } - } while (y != select->segs_in[i].y2); + } while (y != y2); } else selection_add_point (select->points_in, @@ -724,9 +733,22 @@ selection_generate_segs (Selection *select) if (select->num_segs_layer) { + gint i; + GdkSegment *seg; + select->segs_layer = g_new (GdkSegment, select->num_segs_layer); selection_transform_segs (select, segs_layer, select->segs_layer, select->num_segs_layer); + + seg = select->segs_layer; + for (i = 0; i < select->num_segs_layer; i++) + { + seg->x1 = CLAMP (seg->x1, -1, select->shell->disp_width); + seg->y1 = CLAMP (seg->y1, -1, select->shell->disp_height); + seg->x2 = CLAMP (seg->x2, -1, select->shell->disp_width); + seg->y2 = CLAMP (seg->y2, -1, select->shell->disp_height); + seg++; + } } else {