From: Mikko Rasa Date: Sun, 13 Dec 2009 14:04:42 +0000 (+0000) Subject: Fix valgrind warnings X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=dcc8378d809e5d2e53db77234559b0556195e693;p=r2c2.git Fix valgrind warnings --- diff --git a/source/engineer/engineer.cpp b/source/engineer/engineer.cpp index 2c4e726..a2e13f1 100644 --- a/source/engineer/engineer.cpp +++ b/source/engineer/engineer.cpp @@ -112,6 +112,7 @@ Engineer::~Engineer() if(!simulate) trfc_mgr->save("engineer.state"); delete trfc_mgr; + delete server; } void Engineer::place_train(Train &train) @@ -179,6 +180,7 @@ int Engineer::main() Application::main(); + delete root; delete glc; delete wnd; delete dpy; diff --git a/source/libmarklin/catalogue.cpp b/source/libmarklin/catalogue.cpp index 689ad3b..55a5a44 100644 --- a/source/libmarklin/catalogue.cpp +++ b/source/libmarklin/catalogue.cpp @@ -20,6 +20,8 @@ Catalogue::~Catalogue() { for(map::iterator i=tracks.begin(); i!=tracks.end(); ++i) delete i->second; + for(map::iterator i=locos.begin(); i!=locos.end(); ++i) + delete i->second; } TrackType &Catalogue::get_track(unsigned art_nr) const diff --git a/source/libmarklin/control.cpp b/source/libmarklin/control.cpp index 6f7ef74..4f63cc2 100644 --- a/source/libmarklin/control.cpp +++ b/source/libmarklin/control.cpp @@ -36,7 +36,8 @@ Control::~Control() delete i->second; for(map::iterator i=locomotives.begin(); i!=locomotives.end(); ++i) delete i->second; - close(serial_fd); + if(serial_fd>=0) + close(serial_fd); } void Control::open(const string &dev) @@ -212,7 +213,10 @@ void Control::tick() if(debug) cout<<"W: "<=0) + queue.front().send(serial_fd); + else + queue.erase(queue.begin()); } } diff --git a/source/libmarklin/trafficmanager.cpp b/source/libmarklin/trafficmanager.cpp index b7301d3..96cb269 100644 --- a/source/libmarklin/trafficmanager.cpp +++ b/source/libmarklin/trafficmanager.cpp @@ -33,7 +33,8 @@ TrafficManager::TrafficManager(Control &c, Layout &l): if(unsigned tid=(*i)->get_turnout_id()) new Turnout(control, tid, (*i)->get_type().get_n_routes()>=3); if(unsigned sid=(*i)->get_sensor_id()) - new Sensor(control, sid); + if(!control.get_sensors().count(sid)) + new Sensor(control, sid); if(used_tracks.count(*i)==0) {