diff --git a/src/Airports/dynamics.cxx b/src/Airports/dynamics.cxx index d67247a9d..6280ddc7d 100644 --- a/src/Airports/dynamics.cxx +++ b/src/Airports/dynamics.cxx @@ -18,15 +18,14 @@ // // $Id$ -#ifdef HAVE_CONFIG_H -# include -#endif +#include #include #include #include #include +#include #include #include @@ -67,7 +66,10 @@ public: ~ParkingAssignmentPrivate() { - dynamics->releaseParking(parking); + FGAirportDynamicsRef strongRef = dynamics.lock(); + if (strongRef) { + strongRef->releaseParking(parking); + } } void release() @@ -84,7 +86,10 @@ public: unsigned int refCount; FGParkingRef parking; - FGAirportDynamicsRef dynamics; + +// we don't want an owning ref here, otherwise we +// have a circular ownership from AirportDynamics -> us + SGWeakPtr dynamics; }; ParkingAssignment::ParkingAssignment() : diff --git a/src/Airports/dynamics.hxx b/src/Airports/dynamics.hxx index 02e4a6190..7327c3bc7 100644 --- a/src/Airports/dynamics.hxx +++ b/src/Airports/dynamics.hxx @@ -24,7 +24,7 @@ #include -#include +#include #include #include @@ -57,7 +57,7 @@ private: ParkingAssignmentPrivate* _sharedData; }; -class FGAirportDynamics : public SGReferenced +class FGAirportDynamics : public SGWeakReferenced { private: