From eb6a6941846a44897484a66dab4f99dbfcbf65f2 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 7 Mar 2009 13:44:12 +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/2.0-ongoing@4746 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/redirect_box.cc | 43 +++++++++++++++++++++++++++---------- gtk2_ardour/redirect_box.h | 2 +- 2 files changed, 33 insertions(+), 12 deletions(-) diff --git a/gtk2_ardour/redirect_box.cc b/gtk2_ardour/redirect_box.cc index 761426bb3c..5b624578a9 100644 --- a/gtk2_ardour/redirect_box.cc +++ b/gtk2_ardour/redirect_box.cc @@ -158,6 +158,7 @@ RedirectBox::set_route (boost::shared_ptr r) connections.push_back (_route->redirects_changed.connect (mem_fun(*this, &RedirectBox::redisplay_redirects))); connections.push_back (_route->GoingAway.connect (mem_fun (*this, &RedirectBox::route_going_away))); + connections.push_back (_route->name_changed.connect (mem_fun(*this, &RedirectBox::route_name_changed))); redisplay_redirects (0); } @@ -1149,9 +1150,6 @@ RedirectBox::edit_redirect (boost::shared_ptr redirect) plugin_insert->set_gui (plugin_ui); - // change window title when route name is changed - _route->name_changed.connect (bind (mem_fun(*this, &RedirectBox::route_name_changed), plugin_ui, boost::weak_ptr (plugin_insert))); - } else { plugin_ui = reinterpret_cast (plugin_insert->get_gui()); plugin_ui->set_parent (win); @@ -1411,16 +1409,39 @@ RedirectBox::rb_edit () } void -RedirectBox::route_name_changed (void* src, PluginUIWindow* plugin_ui, boost::weak_ptr wpi) +RedirectBox::route_name_changed (void* src) { - ENSURE_GUI_THREAD(bind (mem_fun (*this, &RedirectBox::route_name_changed), src, plugin_ui, wpi)); - boost::shared_ptr pi (wpi.lock()); - + boost::shared_ptr redirect; + boost::shared_ptr insert; + Gtk::TreeModel::Children children = model->children(); - if (pi) { - WindowTitle title(Glib::get_application_name()); - title += generate_redirect_title (pi); - plugin_ui->set_title (title.get_string()); + for (Gtk::TreeModel::Children::iterator iter = children.begin(); iter != children.end(); ++iter) { + Gtk::TreeModel::Row row = *iter; + + redirect= row[columns.redirect]; + + void* gui = redirect->get_gui(); + + if (!gui) { + continue; + } + + /* rename editor windows for sends and plugins */ + + WindowTitle title (Glib::get_application_name()); + + if ((insert = boost::dynamic_pointer_cast (redirect)) == 0) { + boost::shared_ptr send = boost::dynamic_pointer_cast (redirect); + title += send->name(); + static_cast(gui)->set_title (title.get_string()); + } else { + boost::shared_ptr plugin_insert; + + if ((plugin_insert = boost::dynamic_pointer_cast (insert)) != 0) { + title += generate_redirect_title (plugin_insert); + } + static_cast(gui)->set_title (title.get_string()); + } } } diff --git a/gtk2_ardour/redirect_box.h b/gtk2_ardour/redirect_box.h index f75ae0a078..b7d7e329f2 100644 --- a/gtk2_ardour/redirect_box.h +++ b/gtk2_ardour/redirect_box.h @@ -221,7 +221,7 @@ class RedirectBox : public Gtk::HBox, public PluginInterestedObject static void rb_deactivate_all (); static void rb_edit (); - void route_name_changed (void* src, PluginUIWindow* plugin_ui, boost::weak_ptr pi); + void route_name_changed (void* src); std::string generate_redirect_title (boost::shared_ptr pi); };