]> git.tdb.fi Git - r2c2.git/commitdiff
Prevent segfault during layout destruction
authorMikko Rasa <tdb@tdb.fi>
Fri, 5 Jul 2013 15:32:13 +0000 (18:32 +0300)
committerMikko Rasa <tdb@tdb.fi>
Fri, 5 Jul 2013 15:32:13 +0000 (18:32 +0300)
source/libr2c2/trackattachment.cpp
source/libr2c2/trackattachment.h

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"
index 8551250ae7507dc2db2d65ab09a7239a1dd71ed4..d02a443d823a6e77a123f7a56246c453669985fa 100644 (file)
@@ -6,7 +6,7 @@
 
 namespace R2C2 {
 
-class TrackAttachment: public Object
+class TrackAttachment: public Object, public sigc::trackable
 {
 protected:
        TrackIter track;
@@ -27,6 +27,9 @@ protected:
 
 public:
        virtual Track *get_parent() const { return track.track(); }
+
+private:
+       void object_removed(Object &);
 };
 
 } // namespace R2C2