From b669de1e9706148d1a1386050c9f14e620e69fba Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 7 Mar 2009 14:06:19 +0000 Subject: [PATCH] fix crash when renaming a track after deleting a plugin that had a visible GUI/editor window git-svn-id: svn://localhost/ardour2/branches/3.0@4747 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/processor_box.cc | 40 +++++++++++++++++++++++++++--------- gtk2_ardour/processor_box.h | 2 +- 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/gtk2_ardour/processor_box.cc b/gtk2_ardour/processor_box.cc index 7ac5c4a598..886f594ad4 100644 --- a/gtk2_ardour/processor_box.cc +++ b/gtk2_ardour/processor_box.cc @@ -156,6 +156,7 @@ ProcessorBox::set_route (boost::shared_ptr r) connections.push_back (_route->processors_changed.connect (mem_fun(*this, &ProcessorBox::redisplay_processors))); connections.push_back (_route->GoingAway.connect (mem_fun (*this, &ProcessorBox::route_going_away))); + connections.push_back (_route->NameChanged.connect (mem_fun(*this, &ProcessorBox::route_name_changed))); redisplay_processors (); } @@ -1118,9 +1119,6 @@ ProcessorBox::edit_processor (boost::shared_ptr processor) plugin_insert->set_gui (plugin_ui); - // change window title when route name is changed - _route->NameChanged.connect (bind (mem_fun(*this, &ProcessorBox::route_name_changed), plugin_ui, boost::weak_ptr (plugin_insert))); - } else { plugin_ui = reinterpret_cast (plugin_insert->get_gui()); plugin_ui->set_parent (win); @@ -1378,16 +1376,38 @@ ProcessorBox::rb_edit () } void -ProcessorBox::route_name_changed (PluginUIWindow* plugin_ui, boost::weak_ptr wpi) +ProcessorBox::route_name_changed () { - ENSURE_GUI_THREAD(bind (mem_fun (*this, &ProcessorBox::route_name_changed), plugin_ui, wpi)); + ENSURE_GUI_THREAD (mem_fun (*this, &ProcessorBox::route_name_changed)); - boost::shared_ptr pi (wpi.lock()); + boost::shared_ptr processor; + boost::shared_ptr plugin_insert; + boost::shared_ptr send; - if (pi) { - WindowTitle title(Glib::get_application_name()); - title += generate_processor_title (pi); - plugin_ui->set_title (title.get_string()); + Gtk::TreeModel::Children children = model->children(); + + for (Gtk::TreeModel::Children::iterator iter = children.begin(); iter != children.end(); ++iter) { + Gtk::TreeModel::Row row = *iter; + + processor= row[columns.processor]; + + void* gui = processor->get_gui(); + + if (!gui) { + continue; + } + + /* rename editor windows for sends and plugins */ + + WindowTitle title (Glib::get_application_name()); + + if ((send = boost::dynamic_pointer_cast (processor)) != 0) { + title += send->name(); + static_cast(gui)->set_title (title.get_string()); + } else if ((plugin_insert = boost::dynamic_pointer_cast (processor)) != 0) { + title += generate_processor_title (plugin_insert); + static_cast(gui)->set_title (title.get_string()); + } } } diff --git a/gtk2_ardour/processor_box.h b/gtk2_ardour/processor_box.h index c04498a599..60836ac1f6 100644 --- a/gtk2_ardour/processor_box.h +++ b/gtk2_ardour/processor_box.h @@ -222,7 +222,7 @@ class ProcessorBox : public Gtk::HBox, public PluginInterestedObject static void rb_ab_plugins (); static void rb_edit (); - void route_name_changed (PluginUIWindow* plugin_ui, boost::weak_ptr pi); + void route_name_changed (); std::string generate_processor_title (boost::shared_ptr pi); };