After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 464528 - gdk_rectangle_union() and gdk_rectangle_intersect() should ignore "empty" rectangles
gdk_rectangle_union() and gdk_rectangle_intersect() should ignore "empty" rec...
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Backend: X11
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2007-08-07 23:32 UTC by Behdad Esfahbod
Modified: 2016-01-20 18:46 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
[1/1] Allow NULL as the dest parameter for gdk_rectangle_intersect. (1.52 KB, patch)
2007-08-08 20:21 UTC, Xan Lopez
committed Details | Review

Description Behdad Esfahbod 2007-08-07 23:32:20 UTC
If one of the input rects has zero width or height, it should be ignored.  If both are empty, dest should have width and height set to zero (x and y can stay undefined/untouched).
Comment 1 Xan Lopez 2007-08-08 20:12:21 UTC
Probably this should go in a different bug, but while we are at it...
Recently I used gdk_rectangle_intersect just for its boolean return value without being interested at all in the actual intersecting area, but it has a g_return_val_if_fail (dest != NULL, FALSE), forcing you to pass a dummy variable. IMHO a NULL value should be allowed for dest.
Comment 2 Xan Lopez 2007-08-08 20:21:07 UTC
Created attachment 93308 [details] [review]
[1/1] Allow NULL as the dest parameter for gdk_rectangle_intersect.

 gdk/gdkrectangle.c |   20 ++++++++++++--------
 1 files changed, 12 insertions(+), 8 deletions(-)
Comment 3 Björn Lindqvist 2007-08-08 21:46:44 UTC
Should gdk_rectangle_union() really ignore zero sized rectangles? For gdk_rectangle_intersect() it sounds very reasonable, but isn't there a risk that some code might break if the union of 10,10+0x0 and 20,20+10x10 becomes 20,20+10x10 instead of 10,10+20x20?
Comment 4 Behdad Esfahbod 2007-08-08 22:08:48 UTC
(In reply to comment #1)
> Probably this should go in a different bug, but while we are at it...

Filed as bug 464847.

> Recently I used gdk_rectangle_intersect just for its boolean return value
> without being interested at all in the actual intersecting area, but it has a
> g_return_val_if_fail (dest != NULL, FALSE), forcing you to pass a dummy
> variable. IMHO a NULL value should be allowed for dest.
Comment 5 Behdad Esfahbod 2007-08-08 22:10:41 UTC
(In reply to comment #3)
> Should gdk_rectangle_union() really ignore zero sized rectangles? For
> gdk_rectangle_intersect() it sounds very reasonable, but isn't there a risk
> that some code might break if the union of 10,10+0x0 and 20,20+10x10 becomes
> 20,20+10x10 instead of 10,10+20x20?

I agree that there may be code out there relying on the current behavior, but mathematically speaking, zero-sized rectangles should not affect the union.  There is no point inside a zero-sized rectangle afterall.
Comment 6 Matthias Clasen 2007-09-07 03:56:10 UTC
2007-09-06  Matthias Clasen  <mclasen@redhat.com>

        * gdk/gdkrectangle.c (gdk_rectangle_intersect): Allow
        dest to be NULL.  (#464528, Xan Lopez)

Comment 7 Christian Persch 2008-01-11 17:31:58 UTC
Shouldn't the docs point out that dest==NULL is only allowed Since: 2.12 ?
Comment 8 Behdad Esfahbod 2008-01-11 17:52:15 UTC
I don't have any strong opinions either way.  We have at times avoided cluttering docs with such meticulous version keeping.  The idea being that docs for each version document that version (which hopefully will remain valid for future versions too).

Anyway, that belongs to bug 464847, not this one.
Comment 9 Matthias Clasen 2016-01-20 18:46:21 UTC
Decided to just document the current behavior. Its been in place for too long
to change it now.