diff --git a/gtk2_ardour/mixer_ui.cc b/gtk2_ardour/mixer_ui.cc index 67ac5d2007..97485d162e 100644 --- a/gtk2_ardour/mixer_ui.cc +++ b/gtk2_ardour/mixer_ui.cc @@ -385,6 +385,8 @@ Mixer_UI::add_masters (VCAList& vcas) row[track_columns.text] = (*v)->name(); row[track_columns.visible] = true; row[track_columns.vca] = vms; + + vms->CatchDeletion.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::remove_master, this, _1), gui_context()); } redisplay_track_list (); @@ -393,6 +395,21 @@ Mixer_UI::add_masters (VCAList& vcas) void Mixer_UI::remove_master (VCAMasterStrip* vms) { + if (_session && _session->deletion_in_progress()) { + /* its all being taken care of */ + return; + } + + TreeModel::Children rows = track_model->children(); + TreeModel::Children::iterator ri; + + for (ri = rows.begin(); ri != rows.end(); ++ri) { + if ((*ri)[track_columns.vca] == vms) { + PBD::Unwinder uw (_route_deletion_in_progress, true); + track_model->erase (ri); + break; + } + } } void diff --git a/gtk2_ardour/vca_master_strip.cc b/gtk2_ardour/vca_master_strip.cc index 2fb8ed745a..f10596e786 100644 --- a/gtk2_ardour/vca_master_strip.cc +++ b/gtk2_ardour/vca_master_strip.cc @@ -39,6 +39,8 @@ using namespace Gtk; using namespace PBD; using std::string; +PBD::Signal1 VCAMasterStrip::CatchDeletion; + VCAMasterStrip::VCAMasterStrip (Session* s, boost::shared_ptr v) : AxisView (s) , _vca (v) @@ -139,6 +141,21 @@ VCAMasterStrip::VCAMasterStrip (Session* s, boost::shared_ptr v) invalidator (*this), boost::bind (&VCAMasterStrip::update_vca_display, this), gui_context()); + + + _vca->DropReferences.connect (vca_connections, invalidator (*this), boost::bind (&VCAMasterStrip::self_delete, this), gui_context()); + +} + +VCAMasterStrip::~VCAMasterStrip () +{ + CatchDeletion (this); /* EMIT SIGNAL */ +} + +void +VCAMasterStrip::self_delete () +{ + delete this; } void diff --git a/gtk2_ardour/vca_master_strip.h b/gtk2_ardour/vca_master_strip.h index 1e71866310..30d18d54a8 100644 --- a/gtk2_ardour/vca_master_strip.h +++ b/gtk2_ardour/vca_master_strip.h @@ -44,7 +44,11 @@ class VCAMasterStrip : public AxisView, public Gtk::EventBox std::string state_id() const { return "VCAMasterStrip"; } boost::shared_ptr vca() const { return _vca; } - private: + static PBD::Signal1 CatchDeletion; + + private: + ~VCAMasterStrip (); + boost::shared_ptr _vca; Gtk::HBox vertical_padding; ArdourButton name_button; @@ -84,6 +88,7 @@ class VCAMasterStrip : public AxisView, public Gtk::EventBox void vca_property_changed (PBD::PropertyChange const & what_changed); void update_vca_name (); void build_context_menu (); + void self_delete (); };