]> git.saurik.com Git - wxWidgets.git/commitdiff
Don't create a valid wxRegion when using default ctor in wxOSX.
authorVadim Zeitlin <vadim@wxwidgets.org>
Tue, 18 Oct 2011 21:56:40 +0000 (21:56 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Tue, 18 Oct 2011 21:56:40 +0000 (21:56 +0000)
Default constructing a wxRegion created an object that unexpectedly passed
IsOk() test in wxOSX. This was completely unexpected so don't do this and
leave default constructed wxRegion invalid, as in the other ports.

Update DoCombine() to be able to deal with the case of an invalid source
region in a way consistent with the other ports.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@69459 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/osx/carbon/region.h
src/osx/carbon/region.cpp

index 4701c91fac766eb753c4fe6fd2c3bd1aca50bbd4..685c39de66936fff01f8f45aa30e1f23dadffb87 100644 (file)
 class WXDLLIMPEXP_CORE wxRegion : public wxRegionWithCombine
 {
 public:
+    wxRegion() { }
     wxRegion(long x, long y, long w, long h);
     wxRegion(const wxPoint& topLeft, const wxPoint& bottomRight);
     wxRegion(const wxRect& rect);
     wxRegion( WXHRGN hRegion );
     wxRegion(size_t n, const wxPoint *points, wxPolygonFillMode fillStyle = wxODDEVEN_RULE );
-    wxRegion();
 #if wxUSE_IMAGE
     wxRegion(const wxBitmap& bmp)
     {
index 6f703117daaba22e0b2df47b7565574ec5a6de06..ff12238509786e3bf88e01895b88d587fe175d5e 100644 (file)
@@ -68,14 +68,6 @@ public:
 // wxRegion
 //-----------------------------------------------------------------------------
 
-/*!
- * Create an empty region.
- */
-wxRegion::wxRegion()
-{
-    m_refData = new wxRegionRefData();
-}
-
 wxRegion::wxRegion(WXHRGN hRegion )
 {
     wxCFRef< HIShapeRef > shape( (HIShapeRef) hRegion );
@@ -205,6 +197,30 @@ bool wxRegion::DoCombine(const wxRegion& region, wxRegionOp op)
 {
     wxCHECK_MSG( region.IsOk(), false, wxT("invalid wxRegion") );
 
+    // Handle the special case of not initialized (e.g. default constructed)
+    // region as we can't use HIShape functions if we don't have any shape.
+    if ( !m_refData )
+    {
+        switch ( op )
+        {
+            case wxRGN_COPY:
+            case wxRGN_OR:
+            case wxRGN_XOR:
+                // These operations make sense with a null region.
+                *this = region;
+                return true;
+
+            case wxRGN_AND:
+            case wxRGN_DIFF:
+                // Those ones don't really make sense so just leave this region
+                // empty/invalid.
+                return false;
+        }
+
+        wxFAIL_MSG( wxT("Unknown region operation") );
+        return false;
+    }
+
     AllocExclusive();
 
     switch (op)