From 360a903069c7a0dd5e792312ec0eb8921a2aa49d Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 11 Oct 2006 19:50:15 +0000 Subject: [PATCH] make MementoCommand inherit from sigc::trackable so that we don't double-call its object-going-away handler; make big clock float ; do not use shared_ptr in session region signalhandlers, just weak_ptr git-svn-id: svn://localhost/ardour2/trunk@976 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/ardour_ui2.cc | 17 -------------- gtk2_ardour/ardour_ui_ed.cc | 27 +++++++++++++++++++++- gtk2_ardour/automation_line.h | 2 +- libs/ardour/ardour/diskstream.h | 2 +- libs/ardour/ardour/location.h | 2 +- libs/ardour/ardour/plugin.h | 2 +- libs/ardour/ardour/session.h | 7 +++--- libs/ardour/ardour/source.h | 2 +- libs/ardour/ardour/state_manager.h | 2 +- libs/ardour/audioregion.cc | 2 ++ libs/ardour/region.cc | 4 +--- libs/ardour/session.cc | 36 ++++++++++++++++++++---------- libs/gtkmm2ext/gtk_ui.cc | 3 ++- libs/pbd/pbd/destructible.h | 2 +- 14 files changed, 65 insertions(+), 45 deletions(-) diff --git a/gtk2_ardour/ardour_ui2.cc b/gtk2_ardour/ardour_ui2.cc index 9a964fe519..ed7c4951e1 100644 --- a/gtk2_ardour/ardour_ui2.cc +++ b/gtk2_ardour/ardour_ui2.cc @@ -451,23 +451,6 @@ ARDOUR_UI::setup_transport () transport_tearoff_hbox.pack_start (alert_box, false, false); } -void -ARDOUR_UI::setup_clock () -{ - ARDOUR_UI::Clock.connect (bind (mem_fun (big_clock, &AudioClock::set), false)); - - big_clock_window = new Window (WINDOW_TOPLEVEL); - - big_clock_window->set_border_width (0); - big_clock_window->add (big_clock); - big_clock_window->set_title (_("ardour: clock")); - big_clock_window->set_type_hint (Gdk::WINDOW_TYPE_HINT_MENU); - big_clock_window->signal_realize().connect (bind (sigc::ptr_fun (set_decoration), big_clock_window, (Gdk::DECOR_BORDER|Gdk::DECOR_RESIZEH))); - big_clock_window->signal_unmap().connect (bind (sigc::ptr_fun(&ActionManager::uncheck_toggleaction), X_("/Common/ToggleBigClock"))); - - manage_window (*big_clock_window); -} - void ARDOUR_UI::manage_window (Window& win) { diff --git a/gtk2_ardour/ardour_ui_ed.cc b/gtk2_ardour/ardour_ui_ed.cc index eebe33bf58..d7c294c681 100644 --- a/gtk2_ardour/ardour_ui_ed.cc +++ b/gtk2_ardour/ardour_ui_ed.cc @@ -26,6 +26,8 @@ #include +#include + #include "ardour_ui.h" #include "public_editor.h" #include "audio_clock.h" @@ -39,10 +41,12 @@ #include "i18n.h" +using namespace std; using namespace ARDOUR; using namespace PBD; -using namespace Gtk; using namespace Gtkmm2ext; +using namespace Gtk; +using namespace Glib; using namespace sigc; int @@ -558,3 +562,24 @@ ARDOUR_UI::build_menu_bar () menu_bar_base.set_name ("MainMenuBar"); menu_bar_base.add (menu_hbox); } + +void +ARDOUR_UI::setup_clock () +{ + ARDOUR_UI::Clock.connect (bind (mem_fun (big_clock, &AudioClock::set), false)); + + big_clock_window = new Window (WINDOW_TOPLEVEL); + + big_clock_window->set_border_width (0); + big_clock_window->add (big_clock); + big_clock_window->set_title (_("ardour: clock")); + big_clock_window->set_type_hint (Gdk::WINDOW_TYPE_HINT_MENU); + big_clock_window->signal_realize().connect (bind (sigc::ptr_fun (set_decoration), big_clock_window, (Gdk::DECOR_BORDER|Gdk::DECOR_RESIZEH))); + big_clock_window->signal_unmap().connect (bind (sigc::ptr_fun(&ActionManager::uncheck_toggleaction), X_("/Common/ToggleBigClock"))); + + if (editor) { + editor->ensure_float (*big_clock_window); + } + + manage_window (*big_clock_window); +} diff --git a/gtk2_ardour/automation_line.h b/gtk2_ardour/automation_line.h index 52193ecc4c..eb2d204513 100644 --- a/gtk2_ardour/automation_line.h +++ b/gtk2_ardour/automation_line.h @@ -96,7 +96,7 @@ class ControlPoint ShapeType _shape; }; -class AutomationLine : public sigc::trackable, public PBD::StatefulDestructible +class AutomationLine : public PBD::StatefulDestructible { public: AutomationLine (const string & name, TimeAxisView&, ArdourCanvas::Group&, ARDOUR::AutomationList&); diff --git a/libs/ardour/ardour/diskstream.h b/libs/ardour/ardour/diskstream.h index cffe02e859..0afed75348 100644 --- a/libs/ardour/ardour/diskstream.h +++ b/libs/ardour/ardour/diskstream.h @@ -54,7 +54,7 @@ class Session; class Playlist; class IO; - class Diskstream : public sigc::trackable, public PBD::StatefulDestructible + class Diskstream : public PBD::StatefulDestructible { public: enum Flag { diff --git a/libs/ardour/ardour/location.h b/libs/ardour/ardour/location.h index 2dd49847fb..1f1c02d67c 100644 --- a/libs/ardour/ardour/location.h +++ b/libs/ardour/ardour/location.h @@ -42,7 +42,7 @@ using std::string; namespace ARDOUR { -class Location : public sigc::trackable, public PBD::StatefulDestructible +class Location : public PBD::StatefulDestructible { public: enum Flags { diff --git a/libs/ardour/ardour/plugin.h b/libs/ardour/ardour/plugin.h index bc71da84ae..e0b2dfc12b 100644 --- a/libs/ardour/ardour/plugin.h +++ b/libs/ardour/ardour/plugin.h @@ -77,7 +77,7 @@ class PluginInfo { typedef boost::shared_ptr PluginInfoPtr; typedef std::list PluginInfoList; -class Plugin : public PBD::StatefulDestructible, public sigc::trackable +class Plugin : public PBD::StatefulDestructible { public: Plugin (ARDOUR::AudioEngine&, ARDOUR::Session&); diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index ca7c38b281..2453f30cbf 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -103,7 +103,7 @@ using std::string; using std::map; using std::set; -class Session : public sigc::trackable, public PBD::StatefulDestructible +class Session : public PBD::StatefulDestructible { private: @@ -1434,10 +1434,9 @@ class Session : public sigc::trackable, public PBD::StatefulDestructible typedef map > AudioRegionList; AudioRegionList audio_regions; - void region_renamed (boost::shared_ptr); - void region_changed (Change, boost::shared_ptr); void add_region (boost::shared_ptr); - void remove_region (boost::shared_ptr); + void region_changed (Change, boost::weak_ptr); + void remove_region (boost::weak_ptr); int load_regions (const XMLNode& node); diff --git a/libs/ardour/ardour/source.h b/libs/ardour/ardour/source.h index 40594f744b..7e05e628ac 100644 --- a/libs/ardour/ardour/source.h +++ b/libs/ardour/ardour/source.h @@ -33,7 +33,7 @@ namespace ARDOUR { class Session; -class Source : public PBD::StatefulDestructible, public sigc::trackable +class Source : public PBD::StatefulDestructible { public: Source (Session&, std::string name); diff --git a/libs/ardour/ardour/state_manager.h b/libs/ardour/ardour/state_manager.h index 99bfcfc3ce..e123b2cb37 100644 --- a/libs/ardour/ardour/state_manager.h +++ b/libs/ardour/ardour/state_manager.h @@ -13,7 +13,7 @@ namespace ARDOUR { typedef uint32_t state_id_t; -class StateManager : public sigc::trackable +class StateManager : public virtual sigc::trackable { public: struct State { diff --git a/libs/ardour/audioregion.cc b/libs/ardour/audioregion.cc index e403130882..1a09cad032 100644 --- a/libs/ardour/audioregion.cc +++ b/libs/ardour/audioregion.cc @@ -31,6 +31,7 @@ #include #include +#include #include #include @@ -325,6 +326,7 @@ AudioRegion::AudioRegion (SourceList& srcs, const XMLNode& node) AudioRegion::~AudioRegion () { + notify_callbacks (); GoingAway (); /* EMIT SIGNAL */ } diff --git a/libs/ardour/region.cc b/libs/ardour/region.cc index 528bb52a01..ccdf3bdb5d 100644 --- a/libs/ardour/region.cc +++ b/libs/ardour/region.cc @@ -147,9 +147,7 @@ Region::Region (const XMLNode& node) Region::~Region () { - notify_callbacks (); - - /* derived classes must emit GoingAway */ + /* derived classes must call notify_callbacks() and then emit GoingAway */ } void diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index da147fc2d4..d5ff3d223c 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -463,8 +463,15 @@ Session::~Session () cerr << "delete audio regions\n"; #endif /* TRACK_DESTRUCTION */ - for (AudioRegionList::iterator i = audio_regions.begin(); i != audio_regions.end(); ++i) { + for (AudioRegionList::iterator i = audio_regions.begin(); i != audio_regions.end(); ) { + AudioRegionList::iterator tmp; + + tmp = i; + ++tmp; + i->second->drop_references (); + + i = tmp; } audio_regions.clear (); @@ -2447,15 +2454,21 @@ Session::add_region (boost::shared_ptr region) set_dirty(); if (added) { - region->GoingAway.connect (sigc::bind (mem_fun (*this, &Session::remove_region), region)); - region->StateChanged.connect (sigc::bind (mem_fun (*this, &Session::region_changed), region)); + region->GoingAway.connect (sigc::bind (mem_fun (*this, &Session::remove_region), boost::weak_ptr(region))); + region->StateChanged.connect (sigc::bind (mem_fun (*this, &Session::region_changed), boost::weak_ptr(region))); AudioRegionAdded (ar); /* EMIT SIGNAL */ } } void -Session::region_changed (Change what_changed, boost::shared_ptr region) +Session::region_changed (Change what_changed, boost::weak_ptr weak_region) { + boost::shared_ptr region (weak_region.lock ()); + + if (!region) { + return; + } + if (what_changed & Region::HiddenChanged) { /* relay hidden changes */ RegionHiddenChange (region); @@ -2463,15 +2476,15 @@ Session::region_changed (Change what_changed, boost::shared_ptr region) } void -Session::region_renamed (boost::shared_ptr region) -{ - add_region (region); -} - -void -Session::remove_region (boost::shared_ptr region) +Session::remove_region (boost::weak_ptr weak_region) { AudioRegionList::iterator i; + boost::shared_ptr region (weak_region.lock ()); + + if (!region) { + return; + } + boost::shared_ptr ar; bool removed = false; @@ -2482,7 +2495,6 @@ Session::remove_region (boost::shared_ptr region) if ((i = audio_regions.find (region->id())) != audio_regions.end()) { audio_regions.erase (i); removed = true; - cerr << "done\n"; } } else { diff --git a/libs/gtkmm2ext/gtk_ui.cc b/libs/gtkmm2ext/gtk_ui.cc index 55a6bebb02..a2a3404041 100644 --- a/libs/gtkmm2ext/gtk_ui.cc +++ b/libs/gtkmm2ext/gtk_ui.cc @@ -253,7 +253,8 @@ static bool idle_quit () void UI::do_quit () { - Glib::signal_idle().connect (sigc::ptr_fun (idle_quit)); + Gtk::Main::quit (); + // Glib::signal_idle().connect (sigc::ptr_fun (idle_quit)); } void diff --git a/libs/pbd/pbd/destructible.h b/libs/pbd/pbd/destructible.h index 126bd04bba..6692ff564c 100644 --- a/libs/pbd/pbd/destructible.h +++ b/libs/pbd/pbd/destructible.h @@ -5,7 +5,7 @@ namespace PBD { -class Destructible { +class Destructible : public virtual sigc::trackable { public: Destructible() {} virtual ~Destructible () {}