From: Mikko Rasa Date: Fri, 5 Jul 2013 15:32:13 +0000 (+0300) Subject: Prevent segfault during layout destruction X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=e3e3a940c75dcad126d5cf08f0802efdab914568;p=r2c2.git Prevent segfault during layout destruction --- diff --git a/source/libr2c2/trackattachment.cpp b/source/libr2c2/trackattachment.cpp index bed7db8..3d28651 100644 --- a/source/libr2c2/trackattachment.cpp +++ b/source/libr2c2/trackattachment.cpp @@ -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" diff --git a/source/libr2c2/trackattachment.h b/source/libr2c2/trackattachment.h index 8551250..d02a443 100644 --- a/source/libr2c2/trackattachment.h +++ b/source/libr2c2/trackattachment.h @@ -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