]> git.mxchange.org Git - flightgear.git/commitdiff
Fix NaN due to possibly uninitialized _lastViewport in FGPanelNode
authorCsaba Halasz <hcs@vostro.(none)>
Tue, 24 Nov 2009 13:47:59 +0000 (14:47 +0100)
committerTim Moore <timoore@redhat.com>
Tue, 22 Dec 2009 06:18:58 +0000 (07:18 +0100)
src/Model/panelnode.cxx

index 6ac60caaaeb7b41b16b3b70d2526ecd4c6a78e4f..be6889fda55d048d80e0a63044be888fcfbb5d82 100644 (file)
@@ -102,6 +102,11 @@ FGPanelNode::FGPanelNode(SGPropertyNode* props)
         m(1,i) *= 1.0/_ymax;
     }
 
+    _lastViewport[0] = 0;
+    _lastViewport[1] = 0;
+    _lastViewport[2] = 0;
+    _lastViewport[3] = 0;
+
     dirtyBound();
 
     // All done.  Add us to the list
@@ -152,6 +157,11 @@ FGPanelNode::computeBound() const
 
 bool FGPanelNode::doMouseAction(int button, int updown, int x, int y)
 {
+    if (_lastViewport[2] == 0 || _lastViewport[3] == 0) {
+        // we haven't been drawn yet, presumably
+        return false;
+    }
+
     // Covert the screen coordinates to viewport coordinates in the
     // range [0:1], then transform to OpenGL "post projection" coords
     // in [-1:1].  Remember the difference in Y direction!