1
0
Fork 0

Fix the crashes on mini-panel and panel-reload with the KLN89, by removing the multiple inheritance and using an empty shell instrument to forward draw commands from the panel to the complex gps subsystem.

This commit is contained in:
daveluff 2006-01-13 22:07:50 +00:00
parent 28b5a6d8bd
commit 3d5afec340
8 changed files with 59 additions and 8 deletions

View file

@ -825,6 +825,28 @@ FGLayeredInstrument::addTransformation (FGPanelTransformation * transformation)
}
////////////////////////////////////////////////////////////////////////
// Implementation of FGSpecialInstrument.
////////////////////////////////////////////////////////////////////////
FGSpecialInstrument::FGSpecialInstrument (DCLGPS* sb)
: FGPanelInstrument()
{
complex = sb;
}
FGSpecialInstrument::~FGSpecialInstrument ()
{
}
void
FGSpecialInstrument::draw ()
{
complex->draw();
}
////////////////////////////////////////////////////////////////////////
// Implementation of FGInstrumentLayer.

View file

@ -48,6 +48,7 @@
#include <Main/fg_props.hxx>
#include <Input/input.hxx>
#include <Instrumentation/dclgps.hxx>
SG_USING_STD(vector);
SG_USING_STD(map);
@ -428,6 +429,28 @@ protected:
};
/**
* An empty-shell instrument that exists soley in
* order to redirect commands from the panel to a
* complex instrument inherited from SGSubsystem.
*
* Currently the only complex instrument is the KLN89,
* which we've hardwired this to for now.
*/
class FGSpecialInstrument : public FGPanelInstrument
{
public:
FGSpecialInstrument(DCLGPS* sb);
//FGSpecialInstrument (int x, int y, int w, int h);
virtual ~FGSpecialInstrument ();
virtual void draw ();
protected:
DCLGPS* complex;
};
/**
* An instrument layer containing a group of sublayers.
*

View file

@ -787,11 +787,14 @@ readPanel (const SGPropertyNode * root)
// Warning - hardwired size!!!
RenderArea2D* instrument = new RenderArea2D(158, 40, 158, 40, x, y);
// FIXME: shift-F3 (panel reload) kill's us here due to duplicate subsystem!
KLN89* gps = new KLN89(instrument);
panel->addInstrument(gps);
globals->add_subsystem("kln89", gps);
//gps->init(); // init seems to get called automagically.
KLN89* gps = (KLN89*)globals->get_subsystem("kln89");
if(gps == NULL) {
gps = new KLN89(instrument);
globals->add_subsystem("kln89", gps);
}
//gps->init(); // init seems to get called automagically.
FGSpecialInstrument* gpsinst = new FGSpecialInstrument(gps);
panel->addInstrument(gpsinst);
} else {
SG_LOG( SG_COCKPIT, SG_WARN, "Unknown special instrument found" );
}

View file

@ -44,6 +44,7 @@
#include <iostream>
#include <ATC/ATCProjection.hxx>
#include <Main/fg_props.hxx>
#include <simgear/math/point3d.hxx>
SG_USING_STD(cout);

View file

@ -23,6 +23,7 @@
#include "kln89_page_apt.hxx"
#include <ATC/commlist.hxx>
#include <Main/globals.hxx>
// This function is copied from Airports/runways.cxx
// TODO - Make the original properly available and remove this instance!!!!

View file

@ -22,6 +22,7 @@
// $Id$
#include "kln89_page_nav.hxx"
#include <Main/fg_props.hxx>
KLN89NavPage::KLN89NavPage(KLN89* parent)
: KLN89Page(parent) {

View file

@ -26,6 +26,8 @@
#include "dclgps.hxx"
#include <simgear/sg_inlines.h>
#include <simgear/structure/commands.hxx>
#include <Main/fg_props.hxx>
#include <iostream>
SG_USING_STD(cout);

View file

@ -32,8 +32,6 @@
#include <vector>
#include <map>
#include <Cockpit/panel.hxx>
#include <Navaids/navrecord.hxx>
#include <Navaids/navlist.hxx>
#include <Navaids/fixlist.hxx>
@ -203,7 +201,7 @@ typedef vector<GPSPage*> gps_page_list_type;
typedef gps_page_list_type::iterator gps_page_list_itr;
// TODO - merge generic GPS functions instead and split out KLN specific stuff.
class DCLGPS : public SGSubsystem, public FGPanelInstrument {
class DCLGPS : public SGSubsystem {
friend class GPSPage;