Author: spouliot
Date: 2007-12-05 09:47:20 -0500 (Wed, 05 Dec 2007)
New Revision: 90767

Modified:
   trunk/moon/src/ChangeLog
   trunk/moon/src/geometry.cpp
Log:
geometry.cpp: Fix crash when EllipseGeometry is used for clipping (no path 
provided). Fix Build/ComputeBounds when no center point is provided.

Modified: trunk/moon/src/ChangeLog
===================================================================
--- trunk/moon/src/ChangeLog    2007-12-05 13:50:28 UTC (rev 90766)
+++ trunk/moon/src/ChangeLog    2007-12-05 14:47:20 UTC (rev 90767)
@@ -1,3 +1,9 @@
+2007-12-05  Sebastien Pouliot  <[EMAIL PROTECTED]>
+
+       * geometry.cpp: Fix crash when EllipseGeometry is used for clipping
+       (no path provided). Fix Build/ComputeBounds when no center point
+       is provided.
+
 2007-12-05  Rolf Bjarne Kvinge <[EMAIL PROTECTED]> 
 
        * uielement.h, visual.h, uielement.cpp, collection.cpp, control.cpp,

Modified: trunk/moon/src/geometry.cpp
===================================================================
--- trunk/moon/src/geometry.cpp 2007-12-05 13:50:28 UTC (rev 90766)
+++ trunk/moon/src/geometry.cpp 2007-12-05 14:47:20 UTC (rev 90767)
@@ -443,24 +443,28 @@
 void
 EllipseGeometry::Build (Path *shape)
 {
-       Point *pt = ellipse_geometry_get_center (this);
        double rx = ellipse_geometry_get_radius_x (this);
        double ry = ellipse_geometry_get_radius_y (this);
+       Point *pt = ellipse_geometry_get_center (this);
+       double x = pt ? pt->x : 0.0;
+       double y = pt ? pt->y : 0.0;
 
        path = moon_path_renew (path, MOON_PATH_ELLIPSE_LENGTH);
-       moon_ellipse (path, pt->x - rx, pt->y - ry, rx * 2.0, ry * 2.0);
+       moon_ellipse (path, x - rx, y - ry, rx * 2.0, ry * 2.0);
 }
 
 Rect
 EllipseGeometry::ComputeBounds (Path *path)
 {
        // code written to minimize divisions
-       double ht = shape_get_stroke_thickness (path) / 2.0;
+       double ht = (path ? shape_get_stroke_thickness (path) : 1.0) / 2.0;
        double hw = ellipse_geometry_get_radius_x (this) + ht;
        double hh = ellipse_geometry_get_radius_y (this) + ht;
        // point is at center, so left-top corner is minus half width / half 
height
        Point *pt = ellipse_geometry_get_center (this);
-       return Rect (pt->x - hw, pt->y - hh, hw * 2.0, hh * 2.0);
+       double x = pt ? pt->x : 0.0;
+       double y = pt ? pt->y : 0.0;
+       return Rect (x - hw, y - hh, hw * 2.0, hh * 2.0);
 }
 
 //

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

Reply via email to