Fix leaking of dynamics/AI traffic
Use a weak-ref for ParkingAssignment to refer to its owning dynamics, to avoid a circular dependency.
This commit is contained in:
parent
fa76d5b158
commit
3b5721d77e
2 changed files with 12 additions and 7 deletions
|
@ -18,15 +18,14 @@
|
||||||
//
|
//
|
||||||
// $Id$
|
// $Id$
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#include <config.h>
|
||||||
# include <config.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <simgear/compiler.h>
|
#include <simgear/compiler.h>
|
||||||
|
#include <simgear/structure/SGWeakPtr.hxx>
|
||||||
|
|
||||||
#include <Environment/environment_mgr.hxx>
|
#include <Environment/environment_mgr.hxx>
|
||||||
#include <Environment/environment.hxx>
|
#include <Environment/environment.hxx>
|
||||||
|
@ -67,7 +66,10 @@ public:
|
||||||
|
|
||||||
~ParkingAssignmentPrivate()
|
~ParkingAssignmentPrivate()
|
||||||
{
|
{
|
||||||
dynamics->releaseParking(parking);
|
FGAirportDynamicsRef strongRef = dynamics.lock();
|
||||||
|
if (strongRef) {
|
||||||
|
strongRef->releaseParking(parking);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void release()
|
void release()
|
||||||
|
@ -84,7 +86,10 @@ public:
|
||||||
|
|
||||||
unsigned int refCount;
|
unsigned int refCount;
|
||||||
FGParkingRef parking;
|
FGParkingRef parking;
|
||||||
FGAirportDynamicsRef dynamics;
|
|
||||||
|
// we don't want an owning ref here, otherwise we
|
||||||
|
// have a circular ownership from AirportDynamics -> us
|
||||||
|
SGWeakPtr<FGAirportDynamics> dynamics;
|
||||||
};
|
};
|
||||||
|
|
||||||
ParkingAssignment::ParkingAssignment() :
|
ParkingAssignment::ParkingAssignment() :
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
#include <simgear/structure/SGReferenced.hxx>
|
#include <simgear/structure/SGWeakReferenced.hxx>
|
||||||
#include <simgear/timing/timestamp.hxx>
|
#include <simgear/timing/timestamp.hxx>
|
||||||
|
|
||||||
#include <ATC/trafficcontrol.hxx>
|
#include <ATC/trafficcontrol.hxx>
|
||||||
|
@ -57,7 +57,7 @@ private:
|
||||||
ParkingAssignmentPrivate* _sharedData;
|
ParkingAssignmentPrivate* _sharedData;
|
||||||
};
|
};
|
||||||
|
|
||||||
class FGAirportDynamics : public SGReferenced
|
class FGAirportDynamics : public SGWeakReferenced
|
||||||
{
|
{
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Add table
Reference in a new issue