From c71ce6751172eb3b4752c6b48d087a844a36f8e4 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 12 Dec 2004 19:00:42 +0000 Subject: [PATCH] fixed Union() for the case of this rectangle being empty git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30966 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/gdicmn.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/common/gdicmn.cpp b/src/common/gdicmn.cpp index 6cbe1a5d9e..0f73fff839 100644 --- a/src/common/gdicmn.cpp +++ b/src/common/gdicmn.cpp @@ -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; } -- 2.50.0