]> git.tdb.fi Git - r2c2.git/commitdiff
Fix memory leaks and other bad stuff
authorMikko Rasa <tdb@tdb.fi>
Thu, 25 Feb 2010 20:56:20 +0000 (20:56 +0000)
committerMikko Rasa <tdb@tdb.fi>
Thu, 25 Feb 2010 20:56:20 +0000 (20:56 +0000)
source/3d/catalogue.cpp
source/3d/catalogue.h
source/3d/overlay.cpp
source/designer/designer.cpp
source/libmarklin/layout.cpp

index 50f0484542cd1d699f251b4e2585812b90b1bb5a..a5c584be58e4dd0e41f41ff35dbab3bc0fa81deb 100644 (file)
@@ -28,6 +28,12 @@ Catalogue3D::Catalogue3D(const Catalogue &c):
        build_endpoint_mesh();
 }
 
+Catalogue3D::~Catalogue3D()
+{
+       for(map<const TrackType *, TrackType3D *>::iterator i=tracks.begin(); i!=tracks.end(); ++i)
+               delete i->second;
+}
+
 const TrackType3D &Catalogue3D::get_track(const TrackType &tt) const
 {
        map<const TrackType *, TrackType3D *>::const_iterator i = tracks.find(&tt);
index b27683c18a820fd3a7b5dcc05b0fc50194b5d04a..ccbf5887c454c7e2c46701a9947d1fbd3cfa285d 100644 (file)
@@ -27,6 +27,7 @@ private:
 
 public:
        Catalogue3D(const Catalogue &);
+       ~Catalogue3D();
 
        const Catalogue &get_catalogue() const { return catalogue; }
        const TrackType3D &get_track(const TrackType &) const;
index 5f07ac81a6d04ad97bb81ee696b629f8ab965c8a..bc206f987ac6c930275edbce4c9700e29dc1896d 100644 (file)
@@ -30,6 +30,8 @@ Overlay3D::~Overlay3D()
 {
        for(map<string, GL::Mesh *>::iterator i=graphics.begin(); i!=graphics.end(); ++i)
                delete i->second;
+       for(map<const Track3D *, Icon *>::iterator i=icons.begin(); i!=icons.end(); ++i)
+               delete i->second;
 }
 
 void Overlay3D::set_label(const Track3D &track, const string &label)
index 25289093538f3a2722da62a3991a71aa5641a1a5..99655683c1a3bc772d3fe6737d336d2a6d2e7802 100644 (file)
@@ -126,9 +126,12 @@ Designer::Designer(int argc, char **argv):
 
 Designer::~Designer()
 {
+       delete overlay;
        delete root;
-       delete layout;
+       delete pipeline;
+       delete base_object;
        delete layout_3d;
+       delete layout;
        delete cat_layout_3d;
 }
 
@@ -296,6 +299,7 @@ void Designer::key_press(unsigned code, unsigned mod, wchar_t)
                selection.clear();
                for(set<Track *>::iterator i=tracks.begin(); i!=tracks.end(); ++i)
                {
+                       overlay->clear(layout_3d->get_track(**i));
                        layout->remove_track(**i);
                        delete *i;
                }
index afd5f03f81affe1c6cf5a8cb30f8077a0e12daed..4e6620b2e1bcbb6704446efef85aabf5015c3b90 100644 (file)
@@ -25,6 +25,8 @@ Layout::~Layout()
 {
        for(set<Track *>::iterator i=tracks.begin(); i!=tracks.end(); ++i)
                delete *i;
+       for(map<string, Route *>::iterator i=routes.begin(); i!=routes.end(); ++i)
+               delete i->second;
 }
 
 void Layout::add_track(Track &t)