From 2683a9bd2de810e3f6285ab0e750a2a87c264fd1 Mon Sep 17 00:00:00 2001 From: Csaba Halasz Date: Tue, 24 Nov 2009 14:47:59 +0100 Subject: [PATCH] Fix NaN due to possibly uninitialized _lastViewport in FGPanelNode --- src/Model/panelnode.cxx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Model/panelnode.cxx b/src/Model/panelnode.cxx index 6ac60caaa..be6889fda 100644 --- a/src/Model/panelnode.cxx +++ b/src/Model/panelnode.cxx @@ -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! -- 2.39.5