From: Mikko Rasa Date: Sun, 18 Apr 2010 11:28:17 +0000 (+0000) Subject: Plug memory leaks X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=a277834b140eb5987419e2c335032c534a7184cd;p=r2c2.git Plug memory leaks Set correct aspect ratio to camera Add serial to svn:ignore --- diff --git a/source/3d/catalogue.cpp b/source/3d/catalogue.cpp index 57bf053..5229499 100644 --- a/source/3d/catalogue.cpp +++ b/source/3d/catalogue.cpp @@ -36,6 +36,8 @@ Catalogue3D::~Catalogue3D() { for(map::iterator i=tracks.begin(); i!=tracks.end(); ++i) delete i->second; + for(map::iterator i=vehicles.begin(); i!=vehicles.end(); ++i) + delete i->second; } const TrackType3D &Catalogue3D::get_track(const TrackType &tt) const diff --git a/source/3d/track.cpp b/source/3d/track.cpp index ade3d13..baf3519 100644 --- a/source/3d/track.cpp +++ b/source/3d/track.cpp @@ -36,6 +36,8 @@ Track3D::Track3D(Layout3D &l, Track &t): Track3D::~Track3D() { + delete path; + layout.remove_track(*this); layout.get_scene().remove(*this); diff --git a/source/3d/tracktype.cpp b/source/3d/tracktype.cpp index 12a1bb9..a5e0666 100644 --- a/source/3d/tracktype.cpp +++ b/source/3d/tracktype.cpp @@ -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::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); diff --git a/source/3d/tracktype.h b/source/3d/tracktype.h index 980e7b8..56a4b46 100644 --- a/source/3d/tracktype.h +++ b/source/3d/tracktype.h @@ -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; diff --git a/source/engineer/engineer.cpp b/source/engineer/engineer.cpp index d4a0e44..4c9360c 100644 --- a/source/engineer/engineer.cpp +++ b/source/engineer/engineer.cpp @@ -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); } diff --git a/source/libmarklin/timetable.h b/source/libmarklin/timetable.h index 39cff5e..3c76055 100644 --- a/source/libmarklin/timetable.h +++ b/source/libmarklin/timetable.h @@ -10,6 +10,7 @@ Distributed under the GPL #include #include +#include #include #include @@ -18,7 +19,7 @@ namespace Marklin { class Block; class Train; -class Timetable +class Timetable: public sigc::trackable { public: class Loader: public Msp::DataFile::ObjectLoader diff --git a/source/libmarklin/train.cpp b/source/libmarklin/train.cpp index fad6860..6d96339 100644 --- a/source/libmarklin/train.cpp +++ b/source/libmarklin/train.cpp @@ -63,6 +63,8 @@ Train::Train(Layout &l, const LocoType &t, unsigned a): Train::~Train() { + delete control; + delete timetable; for(vector::iterator i=vehicles.begin(); i!=vehicles.end(); ++i) delete *i; layout.remove_train(*this);