]> git.tdb.fi Git - r2c2.git/blobdiff - source/libr2c2/trackattachment.cpp
Prevent segfault during layout destruction
[r2c2.git] / source / libr2c2 / trackattachment.cpp
index bed7db86c79ba47b3cd25b1ec82871eb83bb64c8..3d28651d882395bdd8baab18162e3e201ad3b1bc 100644 (file)
@@ -10,7 +10,9 @@ namespace R2C2 {
 TrackAttachment::TrackAttachment(Layout &l):
        Object(l),
        offset(0)
-{ }
+{
+       layout.signal_object_removed.connect(sigc::mem_fun(this, &TrackAttachment::object_removed));
+}
 
 TrackAttachment::~TrackAttachment()
 {
@@ -92,4 +94,10 @@ float TrackAttachment::find_offset(const TrackIter &trk, const Vector &point)
        return offs;
 }
 
+void TrackAttachment::object_removed(Object &o)
+{
+       if(&o==track.track())
+               track = TrackIter();
+}
+
 } // namespace R2C"