]> git.saurik.com Git - wxWidgets.git/commitdiff
fixed Union() for the case of this rectangle being empty
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 12 Dec 2004 19:00:42 +0000 (19:00 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 12 Dec 2004 19:00:42 +0000 (19:00 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30966 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/gdicmn.cpp

index 6cbe1a5d9e6b0e2313f1f74aa233c805588ba7b8..0f73fff8394a359d98815b703b2109ff523f4aeb 100644 (file)
@@ -138,8 +138,13 @@ wxRect wxRect::operator+(const wxRect& rect) const
 
 wxRect& wxRect::Union(const wxRect& rect)
 {
-    // ignore empty rectangles
-    if ( rect.width && rect.height )
+    // ignore empty rectangles: union with an empty rectangle shouldn't extend
+    // this one to (0, 0)
+    if ( !width || !height )
+    {
+        *this = rect;
+    }
+    else if ( rect.width && rect.height )
     {
         int x1 = wxMin(x, rect.x);
         int y1 = wxMin(y, rect.y);
@@ -151,6 +156,7 @@ wxRect& wxRect::Union(const wxRect& rect)
         width = x2 - x1;
         height = y2 - y1;
     }
+    //else: we're not empty and rect is empty
 
     return *this;
 }