]> git.mxchange.org Git - flightgear.git/commitdiff
Canvas: Make path destroying more robust
authorThomas Geymayer <tomgey@gmail.com>
Thu, 27 Sep 2012 12:41:00 +0000 (14:41 +0200)
committerThomas Geymayer <tomgey@gmail.com>
Thu, 27 Sep 2012 12:41:00 +0000 (14:41 +0200)
src/Canvas/elements/path.cxx

index 65031cfd264d1f18e1d10b2695bf153b96cf649a..a80ba70a2090bd6680ff7cbc74757806dee30ba7 100644 (file)
@@ -56,8 +56,25 @@ namespace canvas
 
       virtual ~PathDrawable()
       {
-        vgDestroyPath(_path);
-        vgDestroyPaint(_paint);
+        if( !_vg_initialized )
+        {
+          if( _path != VG_INVALID_HANDLE )
+            SG_LOG
+            (
+              SG_GL,
+              SG_WARN,
+              "Can't destroy path without OpenVG context: "
+                << _path_element->_node->getPath()
+            );
+          return;
+        }
+
+        if( _path != VG_INVALID_HANDLE )
+          vgDestroyPath(_path);
+        if( _paint != VG_INVALID_HANDLE )
+          vgDestroyPaint(_paint);
+        if( _paint_fill != VG_INVALID_HANDLE )
+          vgDestroyPaint(_paint_fill);
       }
 
       virtual const char* className() const { return "PathDrawable"; }