Fix a FlightPlan lifetime issue.
Route-manager was explicitly deleting its FP, which was incorrect. Switch to correct use of SGSharedPtr to refer to flight plans. Thanks to Roland Haeder for catching this.
This commit is contained in:
parent
1ad9756a4b
commit
16d1c47664
4 changed files with 16 additions and 11 deletions
|
@ -401,12 +401,12 @@ bool FGRouteMgr::loadRoute(const SGPath& p)
|
|||
return true;
|
||||
}
|
||||
|
||||
FlightPlan* FGRouteMgr::flightPlan() const
|
||||
FlightPlanRef FGRouteMgr::flightPlan() const
|
||||
{
|
||||
return _plan;
|
||||
}
|
||||
|
||||
void FGRouteMgr::setFlightPlan(FlightPlan* plan)
|
||||
void FGRouteMgr::setFlightPlan(const FlightPlanRef& plan)
|
||||
{
|
||||
if (plan == _plan) {
|
||||
return;
|
||||
|
@ -414,7 +414,6 @@ void FGRouteMgr::setFlightPlan(FlightPlan* plan)
|
|||
|
||||
if (_plan) {
|
||||
_plan->removeDelegate(this);
|
||||
delete _plan;
|
||||
active->setBoolValue(false);
|
||||
}
|
||||
|
||||
|
|
|
@ -55,8 +55,8 @@ public:
|
|||
|
||||
int currentIndex() const;
|
||||
|
||||
void setFlightPlan(flightgear::FlightPlan* plan);
|
||||
flightgear::FlightPlan* flightPlan() const;
|
||||
void setFlightPlan(const flightgear::FlightPlanRef& plan);
|
||||
flightgear::FlightPlanRef flightPlan() const;
|
||||
|
||||
void clearRoute();
|
||||
|
||||
|
@ -104,7 +104,7 @@ private:
|
|||
bool commandDefineUserWaypoint(const SGPropertyNode* arg);
|
||||
bool commandDeleteUserWaypoint(const SGPropertyNode* arg);
|
||||
|
||||
flightgear::FlightPlan* _plan;
|
||||
flightgear::FlightPlanRef _plan;
|
||||
|
||||
time_t _takeoffTime;
|
||||
time_t _touchdownTime;
|
||||
|
|
|
@ -91,6 +91,11 @@ FlightPlan::~FlightPlan()
|
|||
delete cur;
|
||||
}
|
||||
}
|
||||
|
||||
// delete legs
|
||||
BOOST_FOREACH(Leg* l, _legs) {
|
||||
delete l;
|
||||
}
|
||||
}
|
||||
|
||||
FlightPlan* FlightPlan::clone(const string& newIdent) const
|
||||
|
@ -1193,18 +1198,16 @@ FlightPlan::Delegate::Delegate() :
|
|||
_deleteWithPlan(false),
|
||||
_inner(NULL)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
FlightPlan::Delegate::~Delegate()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void FlightPlan::Delegate::removeInner(Delegate* d)
|
||||
{
|
||||
if (!_inner) {
|
||||
return;
|
||||
throw sg_exception("FlightPlan delegate not found");
|
||||
}
|
||||
|
||||
if (_inner == d) {
|
||||
|
|
|
@ -31,6 +31,9 @@ namespace flightgear
|
|||
{
|
||||
|
||||
class Transition;
|
||||
class FlightPlan;
|
||||
|
||||
typedef SGSharedPtr<FlightPlan> FlightPlanRef;
|
||||
|
||||
class FlightPlan : public RouteBase
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue