I grabbed current CVS last night for the first time in a while, and
got bitten by a bug with the 3D panel support.  Has anyone else
noticed this?  What happens is that on an aircraft with no 2D panel at
all (a4, c172-3d, but oddly not the j3cub), the sim crashes at
startup.  The first problem was that the gcc 3.2 optimizer made a
total hash out of the stack, and gdb was useless.  I don't know if
that's a feature or a bug...

Recompiling with -O1 showed that the led_font object in panel.cxx was
never initialized.  This is a static object that gets created in
Panel::init().  Well, init() doesn't get called for 3D panels, because
it touches static state.  I clearly said so in my comment. :) But
since no 2D panel gets created, this is left null at runtime.

The attached one-liner fixes the problem, but someone with more
knowlege should probably think of a better solution.  We shouldn't be
initializing static state from within a member initializer.  Maybe
there's a need for a "panel subsystem" as separate from the individual
FGPanel objects?

A minor bug, too, is that this leaks memory.  One font gets created
per panel, and then dropped on the floor when the next panel is
initialized.  I'm not sure if it allocates an OpenGL texture object
for each one or not.  If it does, then this is definitely something we
should fix.

Andy

diff -u -r1.1.1.1 panelnode.cxx
--- panelnode.cxx       10 Sep 2002 01:14:08 -0000      1.1.1.1
+++ panelnode.cxx       18 Oct 2002 18:02:08 -0000
@@ -14,6 +14,8 @@
     // it -- those methods touch static state.
     _panel = fgReadPanel(props->getStringValue("path"));

+    _panel->init();
+
     // Read out the pixel-space info
     _xmax = _panel->getWidth();
     _ymax = _panel->getHeight();

-- 
Andrew J. Ross                NextBus Information Systems
Senior Software Engineer      Emeryville, CA
[EMAIL PROTECTED]              http://www.nextbus.com
"Men go crazy in conflagrations.  They only get better one by one."
 - Sting (misquoted)


_______________________________________________
Flightgear-devel mailing list
[EMAIL PROTECTED]
http://mail.flightgear.org/mailman/listinfo/flightgear-devel

Reply via email to