diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2006-10-18 17:42:59 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2006-10-18 17:42:59 +0000 |
commit | 0c31e4c4f3d0bfe37d26a793c934f1b436f8fa0f (patch) | |
tree | 4699d75314f5a1952404408de6bb18edc5984b6f | |
parent | 177b2a2a17ad7ceb75b2149429363dad74a11530 (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
-rw-r--r-- | gtk2_ardour/ardour.menus | 2 | ||||
-rw-r--r-- | gtk2_ardour/editor_ops.cc | 4 | ||||
-rw-r--r-- | gtk2_ardour/route_ui.cc | 14 | ||||
-rw-r--r-- | gtk2_ardour/route_ui.h | 2 | ||||
-rw-r--r-- | gtk2_ardour/send_ui.cc | 11 | ||||
-rw-r--r-- | gtk2_ardour/send_ui.h | 1 | ||||
-rw-r--r-- | libs/ardour/ardour/playlist.h | 4 | ||||
-rw-r--r-- | libs/ardour/audio_playlist.cc | 1 | ||||
-rw-r--r-- | libs/ardour/playlist.cc | 25 | ||||
-rw-r--r-- | libs/ardour/session_state.cc | 2 | ||||
-rw-r--r-- | libs/pbd/pbd/restartable_rw.h | 7 | ||||
-rw-r--r-- | libs/pbd/pbd/shiva.h | 51 |
12 files changed, 76 insertions, 48 deletions
diff --git a/gtk2_ardour/ardour.menus b/gtk2_ardour/ardour.menus index d9019dad06..5ea002da27 100644 --- a/gtk2_ardour/ardour.menus +++ b/gtk2_ardour/ardour.menus @@ -291,8 +291,6 @@ <menuitem action='SendMTC'/> <menuitem action='SendMMC'/> <menuitem action='UseMMC'/> - <menuitem action='SendMIDIfeedback'/> - <menuitem action='UseMIDIcontrol'/> <separator/> <menuitem action='StopPluginsWithTransport'/> <menuitem action='DoNotRunPluginsWhileRecording'/> diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index 5baf37b6b3..0a3104d36a 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -951,8 +951,8 @@ Editor::scroll_forward (float pages) } } - if (ULONG_MAX - cnt < leftmost_frame) { - frame = ULONG_MAX - cnt; + if (max_frames - cnt < leftmost_frame) { + frame = max_frames - cnt; } else { frame = leftmost_frame + cnt; } diff --git a/gtk2_ardour/route_ui.cc b/gtk2_ardour/route_ui.cc index 824bdb7b6d..482f5df22f 100644 --- a/gtk2_ardour/route_ui.cc +++ b/gtk2_ardour/route_ui.cc @@ -26,6 +26,8 @@ #include <ardour/route_group.h> #include <pbd/memento_command.h> +#include <pbd/stacktrace.h> +#include <pbd/shiva.h> #include "route_ui.h" #include "keyboard.h" @@ -44,7 +46,6 @@ using namespace Gtkmm2ext; using namespace ARDOUR; using namespace PBD; - RouteUI::RouteUI (boost::shared_ptr<ARDOUR::Route> rt, ARDOUR::Session& sess, const char* m_name, const char* s_name, const char* r_name) : AxisView(sess), @@ -65,7 +66,8 @@ RouteUI::RouteUI (boost::shared_ptr<ARDOUR::Route> rt, ARDOUR::Session& sess, co set_color (unique_random_color()); } - _route->GoingAway.connect (mem_fun (*this, &RouteUI::route_removed)); + new Shiva<Route,RouteUI> (*_route, *this); + _route->active_changed.connect (mem_fun (*this, &RouteUI::route_active_changed)); mute_button = manage (new BindableToggleButton (_route->mute_control(), m_name )); @@ -95,6 +97,7 @@ RouteUI::RouteUI (boost::shared_ptr<ARDOUR::Route> rt, ARDOUR::Session& sess, co RouteUI::~RouteUI() { + GoingAway (); /* EMIT SIGNAL */ delete mute_menu; } @@ -730,13 +733,6 @@ RouteUI::idle_remove_this_route (RouteUI *rui) } void -RouteUI::route_removed () -{ - ENSURE_GUI_THREAD(mem_fun (*this, &RouteUI::route_removed)); - delete this; -} - -void RouteUI::route_rename () { ArdourPrompter name_prompter (true); diff --git a/gtk2_ardour/route_ui.h b/gtk2_ardour/route_ui.h index ea86041986..6ea867745f 100644 --- a/gtk2_ardour/route_ui.h +++ b/gtk2_ardour/route_ui.h @@ -153,6 +153,8 @@ class RouteUI : public virtual AxisView void reversibly_apply_route_boolean (string name, void (ARDOUR::Route::*func)(bool, void*), bool, void *); void reversibly_apply_audio_track_boolean (string name, void (ARDOUR::AudioTrack::*func)(bool, void*), bool, void *); + + sigc::signal<void> GoingAway; }; #endif /* __ardour_route_ui__ */ diff --git a/gtk2_ardour/send_ui.cc b/gtk2_ardour/send_ui.cc index 88b8b304e4..c4656834a6 100644 --- a/gtk2_ardour/send_ui.cc +++ b/gtk2_ardour/send_ui.cc @@ -98,14 +98,6 @@ SendUI::outs_changed (IOChange change, void* ignored) } void -SendUI::send_going_away () -{ - ENSURE_GUI_THREAD (mem_fun (*this, &SendUI::send_going_away)) - - delete this; -} - -void SendUI::update () { } @@ -146,7 +138,6 @@ void SendUIWindow::send_going_away () { ENSURE_GUI_THREAD (mem_fun (*this, &SendUIWindow::send_going_away)); - - delete this; + delete_when_idle (this); } diff --git a/gtk2_ardour/send_ui.h b/gtk2_ardour/send_ui.h index c8576cab9e..b64e3c8e58 100644 --- a/gtk2_ardour/send_ui.h +++ b/gtk2_ardour/send_ui.h @@ -54,7 +54,6 @@ class SendUI : public Gtk::HBox sigc::connection screen_update_connection; sigc::connection fast_screen_update_connection; - void send_going_away (); void ins_changed (ARDOUR::IOChange, void*); void outs_changed (ARDOUR::IOChange, void*); }; 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__ */ |