]> git.tdb.fi Git - r2c2.git/blobdiff - source/3d/object.cpp
Don't crash if a train has no router
[r2c2.git] / source / 3d / object.cpp
index fcbf2136e7158a98c2dbf7bfc00cd1529549a1cc..cfd7c4a9a75854308aca2a2bcb713ecc0aec98d9 100644 (file)
@@ -1,13 +1,23 @@
+#include "layout.h"
 #include "object.h"
 
 using namespace Msp;
 
 namespace R2C2 {
 
-Object3D::Object3D(Object &o):
+Object3D::Object3D(Layout3D &l, Object &o):
+       layout(l),
        object(o)
 {
        object.signal_moved.connect(sigc::mem_fun(this, &Object3D::moved));
+       moved();
+
+       layout.add(*this);
+}
+
+Object3D::~Object3D()
+{
+       layout.remove(*this);
 }
 
 void Object3D::moved()