Author: spouliot
Date: 2007-09-01 13:55:04 -0400 (Sat, 01 Sep 2007)
New Revision: 85173

Modified:
   trunk/moon/src/ChangeLog
   trunk/moon/src/rect.h
   trunk/moon/src/shape.cpp
Log:
2007-09-01  Sebastien Pouliot  <[EMAIL PROTECTED]>

        * rect.cpp: Fix union with empty rectangles (so x and y are not
        assigned to 0 resulting in large bounds). Fix IsEmpty.
        * shape.cpp: Fix possible division by 0, resulting in infinite 
        values (and much too large bounds)



Modified: trunk/moon/src/ChangeLog
===================================================================
--- trunk/moon/src/ChangeLog    2007-09-01 17:40:40 UTC (rev 85172)
+++ trunk/moon/src/ChangeLog    2007-09-01 17:55:04 UTC (rev 85173)
@@ -1,3 +1,10 @@
+2007-09-01  Sebastien Pouliot  <[EMAIL PROTECTED]>
+
+       * rect.cpp: Fix union with empty rectangles (so x and y are not
+       assigned to 0 resulting in large bounds). Fix IsEmpty.
+       * shape.cpp: Fix possible division by 0, resulting in infinite 
+       values (and much too large bounds)
+
 2007-08-31  Jeffrey Stedfast  <[EMAIL PROTECTED]>
 
        *.cpp: Updated for the slightly different List API (list nodes no

Modified: trunk/moon/src/rect.h
===================================================================
--- trunk/moon/src/rect.h       2007-09-01 17:40:40 UTC (rev 85172)
+++ trunk/moon/src/rect.h       2007-09-01 17:55:04 UTC (rev 85173)
@@ -46,7 +46,7 @@
 
        bool IsEmpty ()
        {
-               return x == 0 && y == 0 && w == 0 && h == 0;
+               return ((w == 0) || (h == 0));
        }
 
        Rect Intersection (const Rect& rect)
@@ -61,6 +61,10 @@
 
        Rect Union (const Rect& rect)
        {
+               if (IsEmpty ())
+                       return Rect (rect);
+               if ((rect.w == 0) || (rect.h == 0))
+                       return Rect (*this);
                Rect result = Rect ();
                result.x = x < rect.x ? x : rect.x;
                result.y = y < rect.y ? y : rect.y;

Modified: trunk/moon/src/shape.cpp
===================================================================
--- trunk/moon/src/shape.cpp    2007-09-01 17:40:40 UTC (rev 85172)
+++ trunk/moon/src/shape.cpp    2007-09-01 17:55:04 UTC (rev 85173)
@@ -1360,7 +1360,7 @@
 }
 
 void
-Path::ComputeBounds()
+Path::ComputeBounds ()
 {
        Shape::ComputeBoundsSlow ();
 }
@@ -1446,8 +1446,8 @@
        Value *vh = GetValueNoDefault (FrameworkElement::HeightProperty);
        Value *vw = GetValueNoDefault (FrameworkElement::WidthProperty);
 
-       double sh = vh ? (h / actual_height) : 1.0;
-       double sw = vw ? (w / actual_width) : 1.0;
+       double sh = (vh && (actual_height > 0.0)) ? (h / actual_height) : 1.0;
+       double sw = (vw && (actual_width > 0.0)) ? (w / actual_width) : 1.0;
        switch (stretch) {
        case StretchFill:
                break;

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to