From abd80d0f64a4b32c3a8cce01c9aa1d6bc7ee64bb Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sat, 5 Dec 2009 03:04:54 +0000 Subject: Clean up and comment PortMatrix event handling a bit. Fix problems with attempts to access Session after it has been destroyed. git-svn-id: svn://localhost/ardour2/branches/3.0@6290 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/ardour_ui_dialogs.cc | 2 +- gtk2_ardour/bundle_manager.cc | 12 +++--- gtk2_ardour/bundle_manager.h | 8 ++-- gtk2_ardour/editor.cc | 2 +- gtk2_ardour/global_port_matrix.cc | 22 ++++++----- gtk2_ardour/global_port_matrix.h | 4 +- gtk2_ardour/io_selector.cc | 16 +++++--- gtk2_ardour/io_selector.h | 8 ++-- gtk2_ardour/mixer_strip.cc | 4 +- gtk2_ardour/port_group.cc | 18 +++++---- gtk2_ardour/port_group.h | 13 +++++-- gtk2_ardour/port_matrix.cc | 71 ++++++++++++++++++++++++------------ gtk2_ardour/port_matrix.h | 6 +-- gtk2_ardour/processor_box.cc | 4 +- gtk2_ardour/return_ui.cc | 2 +- gtk2_ardour/route_params_ui.cc | 6 +-- gtk2_ardour/send_ui.cc | 2 +- gtk2_ardour/session_option_editor.cc | 22 +++++------ 18 files changed, 130 insertions(+), 92 deletions(-) diff --git a/gtk2_ardour/ardour_ui_dialogs.cc b/gtk2_ardour/ardour_ui_dialogs.cc index 63b08db856..3aef3c2919 100644 --- a/gtk2_ardour/ardour_ui_dialogs.cc +++ b/gtk2_ardour/ardour_ui_dialogs.cc @@ -340,7 +340,7 @@ void ARDOUR_UI::create_bundle_manager () { if (bundle_manager == 0) { - bundle_manager = new BundleManager (*session); + bundle_manager = new BundleManager (session); bundle_manager->signal_unmap().connect (sigc::bind (sigc::ptr_fun (&ActionManager::uncheck_toggleaction), X_("/Common/ToggleBundleManager"))); } } diff --git a/gtk2_ardour/bundle_manager.cc b/gtk2_ardour/bundle_manager.cc index 7e3a3e59d9..b638544836 100644 --- a/gtk2_ardour/bundle_manager.cc +++ b/gtk2_ardour/bundle_manager.cc @@ -35,7 +35,7 @@ using namespace std; using namespace ARDOUR; BundleEditorMatrix::BundleEditorMatrix ( - Gtk::Window* parent, Session& session, boost::shared_ptr bundle + Gtk::Window* parent, Session* session, boost::shared_ptr bundle ) : PortMatrix (parent, session, bundle->type()), _bundle (bundle) @@ -174,7 +174,7 @@ BundleEditorMatrix::list_is_global (int dim) const return (dim == OTHER); } -BundleEditor::BundleEditor (Session& session, boost::shared_ptr bundle) +BundleEditor::BundleEditor (Session* session, boost::shared_ptr bundle) : ArdourDialog (_("Edit Bundle")), _matrix (this, session, bundle), _bundle (bundle) { Gtk::Table* t = new Gtk::Table (3, 2); @@ -284,7 +284,7 @@ BundleEditor::on_map () } -BundleManager::BundleManager (Session& session) +BundleManager::BundleManager (Session* session) : ArdourDialog (_("Bundle Manager")), _session (session), edit_button (_("Edit")), delete_button (_("Delete")) { _list_model = Gtk::ListStore::create (_list_model_columns); @@ -292,7 +292,7 @@ BundleManager::BundleManager (Session& session) _tree_view.append_column (_("Name"), _list_model_columns.name); _tree_view.set_headers_visible (false); - boost::shared_ptr bundles = _session.bundles (); + boost::shared_ptr bundles = _session->bundles (); for (BundleList::iterator i = bundles->begin(); i != bundles->end(); ++i) { add_bundle (*i); } @@ -352,7 +352,7 @@ BundleManager::new_clicked () /* Start off with a single channel */ b->add_channel ("1"); - _session.add_bundle (b); + _session->add_bundle (b); add_bundle (b); BundleEditor e (_session, b); @@ -376,7 +376,7 @@ BundleManager::delete_clicked () Gtk::TreeModel::iterator i = _tree_view.get_selection()->get_selected(); if (i) { boost::shared_ptr b = (*i)[_list_model_columns.bundle]; - _session.remove_bundle (b); + _session->remove_bundle (b); _list_model->erase (i); } } diff --git a/gtk2_ardour/bundle_manager.h b/gtk2_ardour/bundle_manager.h index 94078a14af..3beb77e952 100644 --- a/gtk2_ardour/bundle_manager.h +++ b/gtk2_ardour/bundle_manager.h @@ -35,7 +35,7 @@ namespace ARDOUR { class BundleEditorMatrix : public PortMatrix { public: - BundleEditorMatrix (Gtk::Window *, ARDOUR::Session &, boost::shared_ptr); + BundleEditorMatrix (Gtk::Window *, ARDOUR::Session *, boost::shared_ptr); void set_state (ARDOUR::BundleChannel c[2], bool s); PortMatrixNode::State get_state (ARDOUR::BundleChannel c[2]) const; @@ -67,7 +67,7 @@ class BundleEditorMatrix : public PortMatrix class BundleEditor : public ArdourDialog { public: - BundleEditor (ARDOUR::Session &, boost::shared_ptr); + BundleEditor (ARDOUR::Session *, boost::shared_ptr); protected: void on_map (); @@ -88,7 +88,7 @@ class BundleEditor : public ArdourDialog class BundleManager : public ArdourDialog { public: - BundleManager (ARDOUR::Session &); + BundleManager (ARDOUR::Session *); private: @@ -115,7 +115,7 @@ class BundleManager : public ArdourDialog Gtk::TreeView _tree_view; Glib::RefPtr _list_model; ModelColumns _list_model_columns; - ARDOUR::Session& _session; + ARDOUR::Session* _session; Gtk::Button edit_button; Gtk::Button delete_button; }; diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index 817b02ea29..eef401562a 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -4682,7 +4682,7 @@ void Editor::show_global_port_matrix (ARDOUR::DataType t) { if (_global_port_matrix[t] == 0) { - _global_port_matrix[t] = new GlobalPortMatrixWindow (*session, t); + _global_port_matrix[t] = new GlobalPortMatrixWindow (session, t); } _global_port_matrix[t]->show (); diff --git a/gtk2_ardour/global_port_matrix.cc b/gtk2_ardour/global_port_matrix.cc index 8f6e923bd4..327ba41b06 100644 --- a/gtk2_ardour/global_port_matrix.cc +++ b/gtk2_ardour/global_port_matrix.cc @@ -31,7 +31,7 @@ using namespace std; -GlobalPortMatrix::GlobalPortMatrix (Gtk::Window* p, ARDOUR::Session& s, ARDOUR::DataType t) +GlobalPortMatrix::GlobalPortMatrix (Gtk::Window* p, ARDOUR::Session* s, ARDOUR::DataType t) : PortMatrix (p, s, t) { setup_all_ports (); @@ -55,8 +55,8 @@ GlobalPortMatrix::set_state (ARDOUR::BundleChannel c[2], bool s) for (ARDOUR::Bundle::PortList::const_iterator i = in_ports.begin(); i != in_ports.end(); ++i) { for (ARDOUR::Bundle::PortList::const_iterator j = out_ports.begin(); j != out_ports.end(); ++j) { - ARDOUR::Port* p = _session.engine().get_port_by_name (*i); - ARDOUR::Port* q = _session.engine().get_port_by_name (*j); + ARDOUR::Port* p = _session->engine().get_port_by_name (*i); + ARDOUR::Port* q = _session->engine().get_port_by_name (*j); if (p) { if (s) { @@ -73,9 +73,9 @@ GlobalPortMatrix::set_state (ARDOUR::BundleChannel c[2], bool s) } else { /* two non-Ardour ports */ if (s) { - jack_connect (_session.engine().jack (), j->c_str(), i->c_str()); + jack_connect (_session->engine().jack (), j->c_str(), i->c_str()); } else { - jack_disconnect (_session.engine().jack (), j->c_str(), i->c_str()); + jack_disconnect (_session->engine().jack (), j->c_str(), i->c_str()); } } } @@ -85,6 +85,10 @@ GlobalPortMatrix::set_state (ARDOUR::BundleChannel c[2], bool s) PortMatrixNode::State GlobalPortMatrix::get_state (ARDOUR::BundleChannel c[2]) const { + if (_session == 0) { + return PortMatrixNode::NOT_ASSOCIATED; + } + ARDOUR::Bundle::PortList const & in_ports = c[IN].bundle->channel_ports (c[IN].channel); ARDOUR::Bundle::PortList const & out_ports = c[OUT].bundle->channel_ports (c[OUT].channel); if (in_ports.empty() || out_ports.empty()) { @@ -96,15 +100,15 @@ GlobalPortMatrix::get_state (ARDOUR::BundleChannel c[2]) const for (ARDOUR::Bundle::PortList::const_iterator i = in_ports.begin(); i != in_ports.end(); ++i) { for (ARDOUR::Bundle::PortList::const_iterator j = out_ports.begin(); j != out_ports.end(); ++j) { - ARDOUR::Port* p = _session.engine().get_port_by_name (*i); - ARDOUR::Port* q = _session.engine().get_port_by_name (*j); + ARDOUR::Port* p = _session->engine().get_port_by_name (*i); + ARDOUR::Port* q = _session->engine().get_port_by_name (*j); if (!p && !q) { /* two non-Ardour ports; things are slightly more involved */ /* XXX: is this the easiest way to do this? */ /* XXX: isn't this very inefficient? */ - jack_client_t* jack = _session.engine().jack (); + jack_client_t* jack = _session->engine().jack (); jack_port_t* jp = jack_port_by_name (jack, i->c_str()); if (jp == 0) { return PortMatrixNode::NOT_ASSOCIATED; @@ -138,7 +142,7 @@ GlobalPortMatrix::get_state (ARDOUR::BundleChannel c[2]) const return PortMatrixNode::ASSOCIATED; } -GlobalPortMatrixWindow::GlobalPortMatrixWindow (ARDOUR::Session& s, ARDOUR::DataType t) +GlobalPortMatrixWindow::GlobalPortMatrixWindow (ARDOUR::Session* s, ARDOUR::DataType t) : _port_matrix (this, s, t) { switch (t) { diff --git a/gtk2_ardour/global_port_matrix.h b/gtk2_ardour/global_port_matrix.h index 508376a9d1..8e13866f42 100644 --- a/gtk2_ardour/global_port_matrix.h +++ b/gtk2_ardour/global_port_matrix.h @@ -29,7 +29,7 @@ class GlobalPortMatrix : public PortMatrix { public: - GlobalPortMatrix (Gtk::Window*, ARDOUR::Session&, ARDOUR::DataType); + GlobalPortMatrix (Gtk::Window*, ARDOUR::Session*, ARDOUR::DataType); void setup_ports (int); @@ -60,7 +60,7 @@ private: class GlobalPortMatrixWindow : public Gtk::Window { public: - GlobalPortMatrixWindow (ARDOUR::Session&, ARDOUR::DataType); + GlobalPortMatrixWindow (ARDOUR::Session *, ARDOUR::DataType); private: void on_show (); diff --git a/gtk2_ardour/io_selector.cc b/gtk2_ardour/io_selector.cc index 273a03ac87..43052efd11 100644 --- a/gtk2_ardour/io_selector.cc +++ b/gtk2_ardour/io_selector.cc @@ -41,7 +41,7 @@ using namespace ARDOUR; using namespace Gtk; -IOSelector::IOSelector (Gtk::Window* p, ARDOUR::Session& session, boost::shared_ptr io) +IOSelector::IOSelector (Gtk::Window* p, ARDOUR::Session* session, boost::shared_ptr io) : PortMatrix (p, session, io->default_type()) , _io (io) { @@ -67,6 +67,10 @@ IOSelector::IOSelector (Gtk::Window* p, ARDOUR::Session& session, boost::shared_ void IOSelector::setup_ports (int dim) { + if (!_session) { + return; + } + _ports[dim].suspend_signals (); if (dim == _other) { @@ -91,7 +95,7 @@ IOSelector::set_state (ARDOUR::BundleChannel c[2], bool s) for (ARDOUR::Bundle::PortList::const_iterator i = our_ports.begin(); i != our_ports.end(); ++i) { for (ARDOUR::Bundle::PortList::const_iterator j = other_ports.begin(); j != other_ports.end(); ++j) { - Port* f = _session.engine().get_port_by_name (*i); + Port* f = _session->engine().get_port_by_name (*i); if (!f) { return; } @@ -120,7 +124,7 @@ IOSelector::get_state (ARDOUR::BundleChannel c[2]) const for (ARDOUR::Bundle::PortList::const_iterator i = our_ports.begin(); i != our_ports.end(); ++i) { for (ARDOUR::Bundle::PortList::const_iterator j = other_ports.begin(); j != other_ports.end(); ++j) { - Port* f = _session.engine().get_port_by_name (*i); + Port* f = _session->engine().get_port_by_name (*i); /* since we are talking about an IO, our ports should all have an associated Port *, so the above call should never fail */ @@ -152,7 +156,7 @@ IOSelector::list_is_global (int dim) const return (dim == _other); } -IOSelectorWindow::IOSelectorWindow (ARDOUR::Session& session, boost::shared_ptr io, bool /*can_cancel*/) +IOSelectorWindow::IOSelectorWindow (ARDOUR::Session* session, boost::shared_ptr io, bool /*can_cancel*/) : _selector (this, session, io) { set_name ("IOSelectorWindow2"); @@ -209,7 +213,7 @@ IOSelectorWindow::io_name_changed (void* src) set_title (title); } -PortInsertUI::PortInsertUI (Gtk::Window* parent, ARDOUR::Session& sess, boost::shared_ptr pi) +PortInsertUI::PortInsertUI (Gtk::Window* parent, ARDOUR::Session* sess, boost::shared_ptr pi) : input_selector (parent, sess, pi->input()) , output_selector (parent, sess, pi->output()) { @@ -235,7 +239,7 @@ PortInsertUI::finished (IOSelector::Result r) } -PortInsertWindow::PortInsertWindow (ARDOUR::Session& sess, boost::shared_ptr pi, bool can_cancel) +PortInsertWindow::PortInsertWindow (ARDOUR::Session* sess, boost::shared_ptr pi, bool can_cancel) : ArdourDialog ("port insert dialog"), _portinsertui (this, sess, pi), ok_button (can_cancel ? _("OK"): _("Close")), diff --git a/gtk2_ardour/io_selector.h b/gtk2_ardour/io_selector.h index 41cab7d1b1..f61d2cc5c2 100644 --- a/gtk2_ardour/io_selector.h +++ b/gtk2_ardour/io_selector.h @@ -31,7 +31,7 @@ namespace ARDOUR { class IOSelector : public PortMatrix { public: - IOSelector (Gtk::Window*, ARDOUR::Session&, boost::shared_ptr); + IOSelector (Gtk::Window*, ARDOUR::Session *, boost::shared_ptr); void set_state (ARDOUR::BundleChannel c[2], bool); PortMatrixNode::State get_state (ARDOUR::BundleChannel c[2]) const; @@ -73,7 +73,7 @@ class IOSelector : public PortMatrix class IOSelectorWindow : public Gtk::Window { public: - IOSelectorWindow (ARDOUR::Session&, boost::shared_ptr, bool can_cancel = false); + IOSelectorWindow (ARDOUR::Session *, boost::shared_ptr, bool can_cancel = false); IOSelector& selector() { return _selector; } @@ -92,7 +92,7 @@ class IOSelectorWindow : public Gtk::Window class PortInsertUI : public Gtk::HBox { public: - PortInsertUI (Gtk::Window*, ARDOUR::Session&, boost::shared_ptr); + PortInsertUI (Gtk::Window*, ARDOUR::Session *, boost::shared_ptr); void redisplay (); void finished (IOSelector::Result); @@ -105,7 +105,7 @@ class PortInsertUI : public Gtk::HBox class PortInsertWindow : public ArdourDialog { public: - PortInsertWindow (ARDOUR::Session&, boost::shared_ptr, bool can_cancel = false); + PortInsertWindow (ARDOUR::Session *, boost::shared_ptr, bool can_cancel = false); protected: void on_map (); diff --git a/gtk2_ardour/mixer_strip.cc b/gtk2_ardour/mixer_strip.cc index 044719f07b..8e67b4b526 100644 --- a/gtk2_ardour/mixer_strip.cc +++ b/gtk2_ardour/mixer_strip.cc @@ -710,7 +710,7 @@ MixerStrip::edit_output_configuration () output = _route->output (); } - output_selector = new IOSelectorWindow (_session, output); + output_selector = new IOSelectorWindow (&_session, output); } if (output_selector->is_visible()) { @@ -724,7 +724,7 @@ void MixerStrip::edit_input_configuration () { if (input_selector == 0) { - input_selector = new IOSelectorWindow (_session, _route->input()); + input_selector = new IOSelectorWindow (&_session, _route->input()); } if (input_selector->is_visible()) { diff --git a/gtk2_ardour/port_group.cc b/gtk2_ardour/port_group.cc index 7a7fb4ad25..da908cc01f 100644 --- a/gtk2_ardour/port_group.cc +++ b/gtk2_ardour/port_group.cc @@ -238,10 +238,14 @@ PortGroupList::maybe_add_processor_to_list ( /** Gather bundles from around the system and put them in this PortGroupList */ void -PortGroupList::gather (ARDOUR::Session& session, bool inputs, bool allow_dups) +PortGroupList::gather (ARDOUR::Session* session, bool inputs, bool allow_dups) { clear (); + if (session == 0) { + return; + } + boost::shared_ptr bus (new PortGroup (_("Bus"))); boost::shared_ptr track (new PortGroup (_("Track"))); boost::shared_ptr system_mono (new PortGroup (_("System (mono)"))); @@ -254,7 +258,7 @@ PortGroupList::gather (ARDOUR::Session& session, bool inputs, bool allow_dups) the route's input/output and processor bundles together so that they are presented as one bundle in the matrix. */ - boost::shared_ptr routes = session.get_routes (); + boost::shared_ptr routes = session->get_routes (); for (RouteList::const_iterator i = routes->begin(); i != routes->end(); ++i) { @@ -309,7 +313,7 @@ PortGroupList::gather (ARDOUR::Session& session, bool inputs, bool allow_dups) that UserBundles that offer the same ports as a normal bundle get priority */ - boost::shared_ptr b = session.bundles (); + boost::shared_ptr b = session->bundles (); for (BundleList::iterator i = b->begin(); i != b->end(); ++i) { if (boost::dynamic_pointer_cast (*i) && (*i)->ports_are_inputs() == inputs && (*i)->type() == _type) { @@ -338,8 +342,8 @@ PortGroupList::gather (ARDOUR::Session& session, bool inputs, bool allow_dups) /* Ardour stuff */ if (!inputs && _type == DataType::AUDIO) { - ardour->add_bundle (session.the_auditioner()->output()->bundle()); - ardour->add_bundle (session.click_io()->bundle()); + ardour->add_bundle (session->the_auditioner()->output()->bundle()); + ardour->add_bundle (session->click_io()->bundle()); } /* Now find all other ports that we haven't thought of yet */ @@ -347,14 +351,14 @@ PortGroupList::gather (ARDOUR::Session& session, bool inputs, bool allow_dups) std::vector extra_system; std::vector extra_other; - const char **ports = session.engine().get_ports ("", _type.to_jack_type(), inputs ? + const char **ports = session->engine().get_ports ("", _type.to_jack_type(), inputs ? JackPortIsInput : JackPortIsOutput); if (ports) { int n = 0; string client_matching_string; - client_matching_string = session.engine().client_name(); + client_matching_string = session->engine().client_name(); client_matching_string += ':'; while (ports[n]) { diff --git a/gtk2_ardour/port_group.h b/gtk2_ardour/port_group.h index 6940b75093..1fcceb4c19 100644 --- a/gtk2_ardour/port_group.h +++ b/gtk2_ardour/port_group.h @@ -40,9 +40,8 @@ class PortMatrix; class RouteBundle; class PublicEditor; -/** A list of bundles and ports, grouped by some aspect of their - * type e.g. busses, tracks, system. Each group has 0 or more bundles - * and 0 or more ports, where the ports are not in the bundles. +/** A list of bundles grouped by some aspect of their type e.g. busses, tracks, system. + * A group has 0 or more bundles. */ class PortGroup : public sigc::trackable { @@ -62,7 +61,10 @@ public: bool has_port (std::string const &) const; + /** The bundle list has changed in some way; a bundle has been added or removed, or the list cleared etc. */ sigc::signal Changed; + + /** An individual bundle on our list has changed in some way */ sigc::signal BundleChanged; struct BundleRecord { @@ -99,7 +101,7 @@ class PortGroupList : public sigc::trackable void add_group (boost::shared_ptr); void add_group_if_not_empty (boost::shared_ptr); void set_type (ARDOUR::DataType); - void gather (ARDOUR::Session &, bool, bool); + void gather (ARDOUR::Session *, bool, bool); PortGroup::BundleList const & bundles () const; void clear (); void remove_bundle (boost::shared_ptr); @@ -122,7 +124,10 @@ class PortGroupList : public sigc::trackable bool empty () const; + /** The group list has changed in some way; a group has been added or removed, or the list cleared etc. */ sigc::signal Changed; + + /** A bundle in one of our groups has changed */ sigc::signal BundleChanged; private: diff --git a/gtk2_ardour/port_matrix.cc b/gtk2_ardour/port_matrix.cc index 551a98cdda..3fe27b4fdf 100644 --- a/gtk2_ardour/port_matrix.cc +++ b/gtk2_ardour/port_matrix.cc @@ -45,7 +45,7 @@ using namespace ARDOUR; * @param session Our session. * @param type Port type that we are handling. */ -PortMatrix::PortMatrix (Window* parent, Session& session, DataType type) +PortMatrix::PortMatrix (Window* parent, Session* session, DataType type) : Table (3, 3), _session (session), _parent (parent), @@ -95,6 +95,13 @@ PortMatrix::~PortMatrix () delete _menu; } +/** Perform initial and once-only setup. This must be called by + * subclasses after they have set up _ports[] to at least some + * reasonable extent. Two-part initialisation is necessary because + * setting up _ports is largely done by virtual functions in + * subclasses. + */ + void PortMatrix::init () { @@ -109,25 +116,44 @@ PortMatrix::init () _visible_ports[1] = *_ports[1].begin(); } + /* Signal handling is kind of split into two parts: + * + * 1. When _ports[] changes, we call setup(). This essentially sorts out our visual + * representation of the information in _ports[]. + * + * 2. When certain other things change, we need to get our subclass to clear and + * re-fill _ports[], which in turn causes appropriate signals to be raised to + * hook into part (1). + */ + + + /* Part 1: the basic _ports[] change -> reset visuals */ + for (int i = 0; i < 2; ++i) { /* watch for the content of _ports[] changing */ _ports[i].Changed.connect (mem_fun (*this, &PortMatrix::setup)); /* and for bundles in _ports[] changing */ - _ports[i].BundleChanged.connect (mem_fun (*this, &PortMatrix::bundle_changed)); + _ports[i].BundleChanged.connect (sigc::hide (mem_fun (*this, &PortMatrix::setup))); } + /* scrolling stuff */ _hscroll.signal_value_changed().connect (mem_fun (*this, &PortMatrix::hscroll_changed)); _vscroll.signal_value_changed().connect (mem_fun (*this, &PortMatrix::vscroll_changed)); + + /* Part 2: notice when things have changed that require our subclass to clear and refill _ports[] */ + /* watch for routes being added or removed */ - _session.RouteAdded.connect (sigc::hide (mem_fun (*this, &PortMatrix::routes_changed))); + _session->RouteAdded.connect (sigc::hide (mem_fun (*this, &PortMatrix::routes_changed))); /* and also bundles */ - _session.BundleAdded.connect (sigc::hide (mem_fun (*this, &PortMatrix::setup_global_ports))); + _session->BundleAdded.connect (sigc::hide (mem_fun (*this, &PortMatrix::setup_global_ports))); /* and also ports */ - _session.engine().PortRegisteredOrUnregistered.connect (mem_fun (*this, &PortMatrix::setup_all_ports)); + _session->engine().PortRegisteredOrUnregistered.connect (mem_fun (*this, &PortMatrix::setup_global_ports)); + + _session->GoingAway.connect (mem_fun (*this, &PortMatrix::session_going_away)); reconnect_to_routes (); @@ -143,7 +169,7 @@ PortMatrix::reconnect_to_routes () } _route_connections.clear (); - boost::shared_ptr routes = _session.get_routes (); + boost::shared_ptr routes = _session->get_routes (); for (RouteList::iterator i = routes->begin(); i != routes->end(); ++i) { _route_connections.push_back ( (*i)->processors_changed.connect (mem_fun (*this, &PortMatrix::route_processors_changed)) @@ -476,6 +502,8 @@ PortMatrix::disassociate_all_on_channel (boost::weak_ptr bundle, uint32_ void PortMatrix::setup_global_ports () { + ENSURE_GUI_THREAD (mem_fun (*this, &PortMatrix::setup_global_ports)); + for (int i = 0; i < 2; ++i) { if (list_is_global (i)) { setup_ports (i); @@ -486,7 +514,7 @@ PortMatrix::setup_global_ports () void PortMatrix::setup_all_ports () { - if (_session.deletion_in_progress()) { + if (_session->deletion_in_progress()) { return; } @@ -504,9 +532,8 @@ PortMatrix::toggle_show_only_bundles () } _show_only_bundles = !_show_only_bundles; - _body->setup (); - setup_scrollbars (); - queue_draw (); + + setup (); } pair @@ -601,30 +628,20 @@ PortMatrix::add_channel_proxy (boost::weak_ptr w) add_channel (b); } -void -PortMatrix::bundle_changed (ARDOUR::Bundle::Change c) -{ - if (c != Bundle::NameChanged) { - setup_all_ports (); - } - - setup (); -} - void PortMatrix::setup_notebooks () { int const h_current_page = _hnotebook.get_current_page (); int const v_current_page = _vnotebook.get_current_page (); - remove_notebook_pages (_hnotebook); - remove_notebook_pages (_vnotebook); - /* for some reason best known to GTK, erroneous switch_page signals seem to be generated - when adding pages to notebooks, so ignore them */ + when adding or removing pages to or from notebooks, so ignore them */ _ignore_notebook_page_selected = true; + remove_notebook_pages (_hnotebook); + remove_notebook_pages (_vnotebook); + for (PortGroupList::List::const_iterator i = _ports[_row_index].begin(); i != _ports[_row_index].end(); ++i) { HBox* dummy = manage (new HBox); dummy->show (); @@ -728,3 +745,9 @@ PortMatrix::h_page_selected (GtkNotebookPage *, guint n) queue_draw (); } } + +void +PortMatrix::session_going_away () +{ + _session = 0; +} diff --git a/gtk2_ardour/port_matrix.h b/gtk2_ardour/port_matrix.h index 78914f0c25..268c898684 100644 --- a/gtk2_ardour/port_matrix.h +++ b/gtk2_ardour/port_matrix.h @@ -52,7 +52,7 @@ class PortMatrixBody; class PortMatrix : public Gtk::Table { public: - PortMatrix (Gtk::Window*, ARDOUR::Session&, ARDOUR::DataType); + PortMatrix (Gtk::Window*, ARDOUR::Session *, ARDOUR::DataType); ~PortMatrix (); void set_type (ARDOUR::DataType); @@ -157,7 +157,7 @@ protected: inputs and outputs should put outputs in list 0 and inputs in list 1. */ PortGroupList _ports[2]; boost::shared_ptr _visible_ports[2]; - ARDOUR::Session& _session; + ARDOUR::Session* _session; private: @@ -174,12 +174,12 @@ private: void toggle_show_only_bundles (); bool on_scroll_event (GdkEventScroll *); boost::shared_ptr io_from_bundle (boost::shared_ptr) const; - void bundle_changed (ARDOUR::Bundle::Change); void setup_notebooks (); void remove_notebook_pages (Gtk::Notebook &); void v_page_selected (GtkNotebookPage *, guint); void h_page_selected (GtkNotebookPage *, guint); void route_processors_changed (ARDOUR::RouteProcessorChange); + void session_going_away (); Gtk::Window* _parent; diff --git a/gtk2_ardour/processor_box.cc b/gtk2_ardour/processor_box.cc index 6048e84163..2b0c7ccafc 100644 --- a/gtk2_ardour/processor_box.cc +++ b/gtk2_ardour/processor_box.cc @@ -842,7 +842,7 @@ ProcessorBox::choose_send () is closed. */ - IOSelectorWindow *ios = new IOSelectorWindow (_session, send->output(), true); + IOSelectorWindow *ios = new IOSelectorWindow (&_session, send->output(), true); ios->show_all (); /* keep a reference to the send so it doesn't get deleted while @@ -1503,7 +1503,7 @@ ProcessorBox::edit_processor (boost::shared_ptr processor) PortInsertWindow *io_selector; if (port_insert->get_gui() == 0) { - io_selector = new PortInsertWindow (_session, port_insert); + io_selector = new PortInsertWindow (&_session, port_insert); port_insert->set_gui (io_selector); } else { diff --git a/gtk2_ardour/return_ui.cc b/gtk2_ardour/return_ui.cc index 7bd9ca9557..32f84add32 100644 --- a/gtk2_ardour/return_ui.cc +++ b/gtk2_ardour/return_ui.cc @@ -49,7 +49,7 @@ ReturnUI::ReturnUI (Gtk::Window* parent, boost::shared_ptr r, Session& s _vbox.pack_start (_hbox, false, false, false); - io = manage (new IOSelector (parent, se, r->output())); + io = manage (new IOSelector (parent, &se, r->output())); pack_start (_vbox, false, false); diff --git a/gtk2_ardour/route_params_ui.cc b/gtk2_ardour/route_params_ui.cc index d7037159dc..66f7bcc491 100644 --- a/gtk2_ardour/route_params_ui.cc +++ b/gtk2_ardour/route_params_ui.cc @@ -301,13 +301,13 @@ RouteParams_UI::setup_io_frames() cleanup_io_frames(); // input - _input_iosel = new IOSelector (this, *session, _route->input()); + _input_iosel = new IOSelector (this, session, _route->input()); _input_iosel->setup (); input_frame.add (*_input_iosel); input_frame.show_all(); // output - _output_iosel = new IOSelector (this, *session, _route->output()); + _output_iosel = new IOSelector (this, session, _route->output()); _output_iosel->setup (); output_frame.add (*_output_iosel); output_frame.show_all(); @@ -551,7 +551,7 @@ RouteParams_UI::redirect_selected (boost::shared_ptr insert) } else if ((port_insert = boost::dynamic_pointer_cast (insert)) != 0) { - PortInsertUI *portinsert_ui = new PortInsertUI (this, *session, port_insert); + PortInsertUI *portinsert_ui = new PortInsertUI (this, session, port_insert); cleanup_view(); _plugin_conn = port_insert->GoingAway.connect (bind (mem_fun(*this, &RouteParams_UI::redirect_going_away), diff --git a/gtk2_ardour/send_ui.cc b/gtk2_ardour/send_ui.cc index 0e030db091..071adf8627 100644 --- a/gtk2_ardour/send_ui.cc +++ b/gtk2_ardour/send_ui.cc @@ -52,7 +52,7 @@ SendUI::SendUI (Gtk::Window* parent, boost::shared_ptr s, Session& se) _vbox.pack_start (_hbox, false, false, false); _vbox.pack_start (_panners, false, false); - io = manage (new IOSelector (parent, se, s->output())); + io = manage (new IOSelector (parent, &se, s->output())); pack_start (_vbox, false, false); diff --git a/gtk2_ardour/session_option_editor.cc b/gtk2_ardour/session_option_editor.cc index 3e3cc61f04..240c6f5db4 100644 --- a/gtk2_ardour/session_option_editor.cc +++ b/gtk2_ardour/session_option_editor.cc @@ -14,7 +14,7 @@ using namespace ARDOUR; class OptionsPortMatrix : public PortMatrix { public: - OptionsPortMatrix (Gtk::Window* parent, ARDOUR::Session& session) + OptionsPortMatrix (Gtk::Window* parent, ARDOUR::Session* session) : PortMatrix (parent, session, DataType::AUDIO) { _port_group.reset (new PortGroup ("")); @@ -26,12 +26,10 @@ public: void setup_ports (int dim) { - cerr << _session.the_auditioner()->output()->n_ports() << "\n"; - if (dim == OURS) { _port_group->clear (); - _port_group->add_bundle (_session.click_io()->bundle()); - _port_group->add_bundle (_session.the_auditioner()->output()->bundle()); + _port_group->add_bundle (_session->click_io()->bundle()); + _port_group->add_bundle (_session->the_auditioner()->output()->bundle()); } else { _ports[OTHER].gather (_session, true, false); } @@ -42,18 +40,18 @@ public: Bundle::PortList const & our_ports = c[OURS].bundle->channel_ports (c[OURS].channel); Bundle::PortList const & other_ports = c[OTHER].bundle->channel_ports (c[OTHER].channel); - if (c[OURS].bundle == _session.click_io()->bundle()) { + if (c[OURS].bundle == _session->click_io()->bundle()) { for (ARDOUR::Bundle::PortList::const_iterator i = our_ports.begin(); i != our_ports.end(); ++i) { for (ARDOUR::Bundle::PortList::const_iterator j = other_ports.begin(); j != other_ports.end(); ++j) { - Port* f = _session.engine().get_port_by_name (*i); + Port* f = _session->engine().get_port_by_name (*i); assert (f); if (s) { - _session.click_io()->connect (f, *j, 0); + _session->click_io()->connect (f, *j, 0); } else { - _session.click_io()->disconnect (f, *j, 0); + _session->click_io()->disconnect (f, *j, 0); } } } @@ -65,11 +63,11 @@ public: Bundle::PortList const & our_ports = c[OURS].bundle->channel_ports (c[OURS].channel); Bundle::PortList const & other_ports = c[OTHER].bundle->channel_ports (c[OTHER].channel); - if (c[OURS].bundle == _session.click_io()->bundle()) { + if (c[OURS].bundle == _session->click_io()->bundle()) { for (ARDOUR::Bundle::PortList::const_iterator i = our_ports.begin(); i != our_ports.end(); ++i) { for (ARDOUR::Bundle::PortList::const_iterator j = other_ports.begin(); j != other_ports.end(); ++j) { - Port* f = _session.engine().get_port_by_name (*i); + Port* f = _session->engine().get_port_by_name (*i); assert (f); if (f->connected_to (*j)) { @@ -119,7 +117,7 @@ class ConnectionOptions : public OptionEditorBox { public: ConnectionOptions (Gtk::Window* parent, ARDOUR::Session* s) - : _port_matrix (parent, *s) + : _port_matrix (parent, s) { _box->pack_start (_port_matrix); } -- cgit v1.2.3