]> git.mxchange.org Git - simgear.git/commitdiff
canvas::NasalWidget: check for empty setGeometry callback.
authorThomas Geymayer <tomgey@gmail.com>
Sun, 20 Jul 2014 21:31:32 +0000 (23:31 +0200)
committerThomas Geymayer <tomgey@gmail.com>
Sun, 20 Jul 2014 21:31:32 +0000 (23:31 +0200)
simgear/canvas/layout/NasalWidget.cxx

index d3feb9b47f26ebc428d767852ec42f58b2b9e384..9d31a4559e30a79b66560b85f699e4bcac846d1b 100644 (file)
@@ -19,6 +19,7 @@
 #include "NasalWidget.hxx"
 
 #include <simgear/canvas/Canvas.hxx>
+#include <simgear/nasal/cppbind/NasalContext.hxx>
 #include <simgear/nasal/cppbind/Ghost.hxx>
 
 namespace simgear
@@ -56,13 +57,17 @@ namespace canvas
   void NasalWidget::setGeometry(const SGRect<int>& geom)
   {
     if( _geometry != geom )
+    {
       _geometry = geom;
-    else if( !(_flags & LAYOUT_DIRTY) || !_set_geometry )
+      _flags |= LAYOUT_DIRTY;
+    }
+
+    if( !_set_geometry || !(_flags & LAYOUT_DIRTY) )
       return;
 
-    naContext c = naNewContext();
     try
     {
+      nasal::Context c;
       _set_geometry(nasal::to_nasal(c, this), geom);
       _flags &= ~LAYOUT_DIRTY;
     }
@@ -74,7 +79,6 @@ namespace canvas
         "NasalWidget::setGeometry: callback error: '" << ex.what() << "'"
       );
     }
-    naFreeContext(c);
   }
 
   //----------------------------------------------------------------------------