Melchior FRANZ a écrit :
> * Melchior FRANZ -- Saturday 15 April 2006 20:58:
>   
>> Apart from the crashes ATC worked and works nicely, and it would really
>> be great if one could now have it enabled and not have to fear abrupt
>> exits.
>>     
>
> Damn, I still get crashes in tower.cxx ...
>   


What about applying the simple patch attached. It doesn't cure the
double entries problem, but it ensures that no valid memory is returned
to the system before all references on it are released.

-Fred

-- 
Frédéric Bouvier
http://frfoto.free.fr         Photo gallery - album photo
http://www.fotolia.fr/p/2278  Other photo gallery
http://fgsd.sourceforge.net/  FlightGear Scenery Designer

cvs -z4 -w -q diff -u -wb -- src\ATC\tower.cxx src\ATC\tower.hxx (in directory 
I:\FlightGear\cvs\FlightGear\)
Index: src/ATC/tower.cxx
===================================================================
RCS file: /var/cvs/FlightGear-0.9/FlightGear/src/ATC/tower.cxx,v
retrieving revision 1.56
diff -u -w -b -r1.56 tower.cxx
--- src/ATC/tower.cxx   15 Apr 2006 18:48:59 -0000      1.56
+++ src/ATC/tower.cxx   18 Apr 2006 21:01:18 -0000
@@ -2164,7 +2164,7 @@
        //cout << ident << " RemovePlane called for " << ID << '\n';
        // We have to be careful here - we want to erase the plane from all 
lists it is in,
        // but we can only delete it once, AT THE END.
-       TowerPlaneRec* t = NULL;
+       SGSharedPtr<TowerPlaneRec> t = NULL;

        tower_plane_rec_list_iterator twrItr;
        for(twrItr = appList.begin(); twrItr != appList.end(); twrItr++) {
                if((*twrItr)->plane.callsign == ID) {
@@ -2224,8 +2224,6 @@
                        //break;
                }
        }
-       // And finally, delete the record.
-       delete t;
 }
 
 void FGTower::ReportDownwind(const string& ID) {
Index: src/ATC/tower.hxx
===================================================================
RCS file: /var/cvs/FlightGear-0.9/FlightGear/src/ATC/tower.hxx,v
retrieving revision 1.33
diff -u -w -b -r1.33 tower.hxx
--- src/ATC/tower.hxx   17 Apr 2006 17:08:58 -0000      1.33
+++ src/ATC/tower.hxx   18 Apr 2006 20:59:45 -0000
@@ -24,6 +24,7 @@
 #include <simgear/compiler.h>
 #include <simgear/math/point3d.hxx>
 #include <simgear/misc/sgstream.hxx>
+#include <simgear/structure/SGReferenced.hxx>

 #include <plib/sg.h>
 
 #include STL_IOSTREAM
@@ -67,7 +68,7 @@
 
 // Structure for holding details of a plane under tower control.
 // Not fixed yet - may include more stuff later.
-class TowerPlaneRec {
+class TowerPlaneRec : public SGReferenced {

        
 public:
        
@@ -113,7 +114,7 @@
 };
 
 
-typedef list < TowerPlaneRec* > tower_plane_rec_list_type;
+typedef list < SGSharedPtr<TowerPlaneRec> > tower_plane_rec_list_type;

 typedef tower_plane_rec_list_type::iterator tower_plane_rec_list_iterator;
 typedef tower_plane_rec_list_type::const_iterator 
tower_plane_rec_list_const_iterator;
 

Reply via email to