]> git.tdb.fi Git - r2c2.git/commitdiff
Plug memory leaks
authorMikko Rasa <tdb@tdb.fi>
Sun, 18 Apr 2010 11:28:17 +0000 (11:28 +0000)
committerMikko Rasa <tdb@tdb.fi>
Sun, 18 Apr 2010 11:28:17 +0000 (11:28 +0000)
Set correct aspect ratio to camera
Add serial to svn:ignore

source/3d/catalogue.cpp
source/3d/track.cpp
source/3d/tracktype.cpp
source/3d/tracktype.h
source/engineer/engineer.cpp
source/libmarklin/timetable.h
source/libmarklin/train.cpp

index 57bf0533918d67f7ac95d101d1896aa6f3d727f6..5229499ad505f93912ca25784689ca00b53e9034 100644 (file)
@@ -36,6 +36,8 @@ Catalogue3D::~Catalogue3D()
 {
        for(map<const TrackType *, TrackType3D *>::iterator i=tracks.begin(); i!=tracks.end(); ++i)
                delete i->second;
+       for(map<const VehicleType *, VehicleType3D *>::iterator i=vehicles.begin(); i!=vehicles.end(); ++i)
+               delete i->second;
 }
 
 const TrackType3D &Catalogue3D::get_track(const TrackType &tt) const
index ade3d132bcef669759bff1c6796e14699a9ce177..baf35195ff3dd454ebd693cfb53a8b1eb6ae4ed6 100644 (file)
@@ -36,6 +36,8 @@ Track3D::Track3D(Layout3D &l, Track &t):
 
 Track3D::~Track3D()
 {
+       delete path;
+
        layout.remove_track(*this);
        layout.get_scene().remove(*this);
 
index 12a1bb92a15df585e426e381cc30ab5331877b3f..a5e06665b3d589a5116a72d693beca5851beee0d 100644 (file)
@@ -135,6 +135,12 @@ TrackType3D::TrackType3D(const Catalogue3D &cat3d, const TrackType &tt):
        border.erase(graham_scan(border.begin(), border.end()), border.end());
 }
 
+TrackType3D::~TrackType3D()
+{
+       for(vector<GL::Mesh *>::iterator i=path_meshes.begin(); i!=path_meshes.end(); ++i)
+               delete *i;
+}
+
 void TrackType3D::get_bounds(float angle, Point &minp, Point &maxp) const
 {
        float c = cos(-angle);
index 980e7b82c843a483ffcf34083117119a0ab57f0b..56a4b46ac11c091e460fa8f075bb6f89203a8f96 100644 (file)
@@ -31,6 +31,7 @@ private:
 
 public:
        TrackType3D(const Catalogue3D &, const TrackType &);
+       ~TrackType3D();
 
        void get_bounds(float, Point &, Point &) const;
        const Msp::GL::Mesh &get_path_mesh(unsigned) const;
index d4a0e4446ccb1cda3065bb68f84893703ecdc92d..4c9360c54fee891de134c92f29f3373e1cb177de 100644 (file)
@@ -324,6 +324,7 @@ void Engineer::view_all()
        camera.set_position(pos);
        camera.set_up_direction(up);
        camera.set_look_direction(GL::Vector3(0, 0, -1));
+       camera.set_aspect(float(window.get_width())/window.get_height());
        camera.set_depth_clip(pos.z*0.5, pos.z*1.5);
 }
 
index 39cff5ee6b2b14a077445521783ac2039630acd9..3c76055e712e6d54d82d29bff77b3511da4e0248 100644 (file)
@@ -10,6 +10,7 @@ Distributed under the GPL
 
 #include <string>
 #include <vector>
+#include <sigc++/trackable.h>
 #include <msp/datafile/objectloader.h>
 #include <msp/time/timestamp.h>
 
@@ -18,7 +19,7 @@ namespace Marklin {
 class Block;
 class Train;
 
-class Timetable
+class Timetable: public sigc::trackable
 {
 public:
        class Loader: public Msp::DataFile::ObjectLoader<Timetable>
index fad68605e7c70952faf21ac6931616a7114a7f70..6d963396e3baa81bb5cdffa26b8b0546adfad139 100644 (file)
@@ -63,6 +63,8 @@ Train::Train(Layout &l, const LocoType &t, unsigned a):
 
 Train::~Train()
 {
+       delete control;
+       delete timetable;
        for(vector<Vehicle *>::iterator i=vehicles.begin(); i!=vehicles.end(); ++i)
                delete *i;
        layout.remove_train(*this);