summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2006-10-18 17:42:59 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2006-10-18 17:42:59 +0000
commit0c31e4c4f3d0bfe37d26a793c934f1b436f8fa0f (patch)
tree4699d75314f5a1952404408de6bb18edc5984b6f /libs
parent177b2a2a17ad7ceb75b2149429363dad74a11530 (diff)
more object lifetime management fixes, plus a couple of tiny cleanups
git-svn-id: svn://localhost/ardour2/trunk@992 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs')
-rw-r--r--libs/ardour/ardour/playlist.h4
-rw-r--r--libs/ardour/audio_playlist.cc1
-rw-r--r--libs/ardour/playlist.cc25
-rw-r--r--libs/ardour/session_state.cc2
-rw-r--r--libs/pbd/pbd/restartable_rw.h7
-rw-r--r--libs/pbd/pbd/shiva.h51
6 files changed, 66 insertions, 24 deletions
diff --git a/libs/ardour/ardour/playlist.h b/libs/ardour/ardour/playlist.h
index 04f2df0ae9..4c2e75c6c9 100644
--- a/libs/ardour/ardour/playlist.h
+++ b/libs/ardour/ardour/playlist.h
@@ -168,7 +168,7 @@ class Playlist : public StateManager, public PBD::StatefulDestructible {
friend class RegionLock;
- RegionList regions;
+ RegionList regions; /* the current list of regions in the playlist */
string _name;
Session& _session;
mutable gint block_notifications;
@@ -221,7 +221,7 @@ class Playlist : public StateManager, public PBD::StatefulDestructible {
void mark_session_dirty();
- void region_changed_proxy (Change, boost::shared_ptr<Region>);
+ void region_changed_proxy (Change, boost::weak_ptr<Region>);
virtual bool region_changed (Change, boost::shared_ptr<Region>);
void region_bounds_changed (Change, boost::shared_ptr<Region>);
diff --git a/libs/ardour/audio_playlist.cc b/libs/ardour/audio_playlist.cc
index 526003e6b2..2d2f4e5365 100644
--- a/libs/ardour/audio_playlist.cc
+++ b/libs/ardour/audio_playlist.cc
@@ -126,7 +126,6 @@ AudioPlaylist::AudioPlaylist (const AudioPlaylist& other, nframes_t start, nfram
AudioPlaylist::~AudioPlaylist ()
{
set<Crossfade*> all_xfades;
- set<Region*> all_regions;
GoingAway (); /* EMIT SIGNAL */
diff --git a/libs/ardour/playlist.cc b/libs/ardour/playlist.cc
index 38c7e387f8..3ef817cc55 100644
--- a/libs/ardour/playlist.cc
+++ b/libs/ardour/playlist.cc
@@ -532,7 +532,8 @@ Playlist::add_region_internal (boost::shared_ptr<Region> region, nframes_t posit
}
}
- region->StateChanged.connect (sigc::bind (mem_fun (this, &Playlist::region_changed_proxy), region));
+ region->StateChanged.connect (sigc::bind (mem_fun (this, &Playlist::region_changed_proxy),
+ boost::weak_ptr<Region> (region)));
}
void
@@ -1148,8 +1149,14 @@ Playlist::region_bounds_changed (Change what_changed, boost::shared_ptr<Region>
}
void
-Playlist::region_changed_proxy (Change what_changed, boost::shared_ptr<Region> region)
+Playlist::region_changed_proxy (Change what_changed, boost::weak_ptr<Region> weak_region)
{
+ boost::shared_ptr<Region> region (weak_region.lock());
+
+ if (!region) {
+ return;
+ }
+
/* this makes a virtual call to the right kind of playlist ... */
region_changed (what_changed, region);
@@ -1373,21 +1380,15 @@ Playlist::set_state (const XMLNode& node)
if (child->name() == "Region") {
-#if 0
if ((prop = child->property ("id")) == 0) {
error << _("region state node has no ID, ignored") << endmsg;
continue;
}
- ID id = prop->value ();
-
- if ((region = region_by_id (id)) == 0) {
-#endif
- if ((region = RegionFactory::create (_session, *child, true)) == 0) {
- error << _("Playlist: cannot create region from state file") << endmsg;
- continue;
- }
-// }
+ if ((region = RegionFactory::create (_session, *child, true)) == 0) {
+ error << _("Playlist: cannot create region from state file") << endmsg;
+ continue;
+ }
add_region (region, region->position(), 1.0, false);
diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc
index e577dfb94a..3c51bbfaf8 100644
--- a/libs/ardour/session_state.cc
+++ b/libs/ardour/session_state.cc
@@ -1296,8 +1296,6 @@ Session::XMLRegionFactory (const XMLNode& node, bool full)
cerr << "no name for this region\n";
abort ();
}
- cerr << "name of this region = " << prop->value() << endl;
-
if ((prop = node.property (X_("source-0"))) == 0) {
if ((prop = node.property ("source")) == 0) {
diff --git a/libs/pbd/pbd/restartable_rw.h b/libs/pbd/pbd/restartable_rw.h
deleted file mode 100644
index ee84e4e295..0000000000
--- a/libs/pbd/pbd/restartable_rw.h
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef __libmisc_restartable_rw__h__
-#define __libmisc_restartable_rw__h__
-
-extern int restartable_write (int fd, unsigned char *buf, size_t cnt);
-extern int restartable_read (int fd, unsigned char *buf, size_t cnt);
-
-#endif // __libmisc_restartable_rw__h__
diff --git a/libs/pbd/pbd/shiva.h b/libs/pbd/pbd/shiva.h
new file mode 100644
index 0000000000..5110f48332
--- /dev/null
+++ b/libs/pbd/pbd/shiva.h
@@ -0,0 +1,51 @@
+#ifndef __pbd_shiva_h__
+#define __pbd_shiva_h__
+
+#include <sigc++/sigc++.h>
+
+namespace PBD {
+
+template<typename ObjectWithGoingAway, typename ObjectToBeDestroyed>
+
+/* named after the Hindu god Shiva, The Destroyer */
+
+class Shiva {
+ public:
+ Shiva (ObjectWithGoingAway& emitter, ObjectToBeDestroyed& receiver) {
+
+ /* if the emitter goes away, destroy the receiver */
+
+ _connection1 = emitter.GoingAway.connect
+ (sigc::bind (sigc::mem_fun
+ (*this, &Shiva<ObjectWithGoingAway,ObjectToBeDestroyed>::destroy),
+ &receiver));
+
+ /* if the receiver goes away, forget all this nonsense */
+
+ _connection2 = receiver.GoingAway.connect
+ (sigc::mem_fun (*this, &Shiva<ObjectWithGoingAway,ObjectToBeDestroyed>::forget));
+ }
+
+ ~Shiva() {
+ forget ();
+ }
+
+ private:
+ sigc::connection _connection1;
+ sigc::connection _connection2;
+
+ void destroy (ObjectToBeDestroyed* obj) {
+ delete obj;
+ forget ();
+ }
+
+ void forget () {
+ _connection1.disconnect ();
+ _connection2.disconnect ();
+ }
+
+};
+
+}
+
+#endif /* __pbd_shiva_h__ */