make MementoCommand inherit from sigc::trackable so that we don't double-call its...
authorPaul Davis <paul@linuxaudiosystems.com>
Wed, 11 Oct 2006 19:50:15 +0000 (19:50 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Wed, 11 Oct 2006 19:50:15 +0000 (19:50 +0000)
git-svn-id: svn://localhost/ardour2/trunk@976 d708f5d6-7413-0410-9779-e7cbd77b26cf

14 files changed:
gtk2_ardour/ardour_ui2.cc
gtk2_ardour/ardour_ui_ed.cc
gtk2_ardour/automation_line.h
libs/ardour/ardour/diskstream.h
libs/ardour/ardour/location.h
libs/ardour/ardour/plugin.h
libs/ardour/ardour/session.h
libs/ardour/ardour/source.h
libs/ardour/ardour/state_manager.h
libs/ardour/audioregion.cc
libs/ardour/region.cc
libs/ardour/session.cc
libs/gtkmm2ext/gtk_ui.cc
libs/pbd/pbd/destructible.h

index 9a964fe5195c93093361c76312fff8b34805d8f9..ed7c4951e1fa43be87691e2f14c58641ce1fe60b 100644 (file)
@@ -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_("<Actions>/Common/ToggleBigClock")));
-
-       manage_window (*big_clock_window);
-}
-
 void
 ARDOUR_UI::manage_window (Window& win)
 {
index eebe33bf58fdadb3dc5697ecc98a76b68445dc77..d7c294c6815a14499c78bbd74aac0719ab5ca838 100644 (file)
@@ -26,6 +26,8 @@
 
 #include <pbd/pathscanner.h>
 
+#include <gtkmm2ext/utils.h>
+
 #include "ardour_ui.h"
 #include "public_editor.h"
 #include "audio_clock.h"
 
 #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_("<Actions>/Common/ToggleBigClock")));
+
+       if (editor) {
+               editor->ensure_float (*big_clock_window);
+       }
+
+       manage_window (*big_clock_window);
+}
index 52193ecc4cf5d10a846308950d47391d2ef84800..eb2d2045134ac9fb4c17aaa553b380dccdaf35ce 100644 (file)
@@ -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&);
index cffe02e8598debd32142de50a711cf05170c2aac..0afed75348e3e86b0e6a91a34611abeb1d00fd4f 100644 (file)
@@ -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 {
index 2dd49847fb21b444a05f6dbfb36fdf85e377464b..1f1c02d67cac36d19de28437576bb90119f66192 100644 (file)
@@ -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 {
index bc71da84aee4177f945fb372285bcfef63955822..e0b2dfc12b21025c65cf70027208e35aaeaaee97 100644 (file)
@@ -77,7 +77,7 @@ class PluginInfo {
 typedef boost::shared_ptr<PluginInfo> PluginInfoPtr;
 typedef std::list<PluginInfoPtr> PluginInfoList;
 
-class Plugin : public PBD::StatefulDestructible, public sigc::trackable
+class Plugin : public PBD::StatefulDestructible
 {
   public:
        Plugin (ARDOUR::AudioEngine&, ARDOUR::Session&);
index ca7c38b2814e2b91905dc909e08e30e2bee0c121..2453f30cbf80bac19713eaf24771cc5dea68d93b 100644 (file)
@@ -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<PBD::ID,boost::shared_ptr<AudioRegion> > AudioRegionList;
        AudioRegionList audio_regions;
        
-       void region_renamed (boost::shared_ptr<Region>);
-       void region_changed (Change, boost::shared_ptr<Region>);
        void add_region (boost::shared_ptr<Region>);
-       void remove_region (boost::shared_ptr<Region>);
+       void region_changed (Change, boost::weak_ptr<Region>);
+       void remove_region (boost::weak_ptr<Region>);
 
        int load_regions (const XMLNode& node);
 
index 40594f744b22f9435333101cb6048fd8141541c9..7e05e628ac3491af42de441645f665c2bc0b8f64 100644 (file)
@@ -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);
index 99bfcfc3ceed22055d93be3a364791deab644db6..e123b2cb3775adcb72bd0077ebde1fd3cd6bd036 100644 (file)
@@ -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 {
index e40313088279161eb4eee4591ba69cd5fcd5b2f3..1a09cad032a707f77d8c1c0604ede171dabedc00 100644 (file)
@@ -31,6 +31,7 @@
 
 #include <pbd/basename.h>
 #include <pbd/xml++.h>
+#include <pbd/stacktrace.h>
 
 #include <ardour/audioregion.h>
 #include <ardour/session.h>
@@ -325,6 +326,7 @@ AudioRegion::AudioRegion (SourceList& srcs, const XMLNode& node)
 
 AudioRegion::~AudioRegion ()
 {
+       notify_callbacks ();
        GoingAway (); /* EMIT SIGNAL */
 }
 
index 528bb52a012d9cf9070ff613c4ac16aa697d441e..ccdf3bdb5d890ebfd701c4411151fbe96e7e3add 100644 (file)
@@ -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
index da147fc2d4666a81d7ceabf9b2c53a1596c80508..d5ff3d223c1bced847b1dd283777cac2b4d0a974 100644 (file)
@@ -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> 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)));
+               region->StateChanged.connect (sigc::bind (mem_fun (*this, &Session::region_changed), boost::weak_ptr<Region>(region)));
                AudioRegionAdded (ar); /* EMIT SIGNAL */
        }
 }
 
 void
-Session::region_changed (Change what_changed, boost::shared_ptr<Region> region)
+Session::region_changed (Change what_changed, boost::weak_ptr<Region> weak_region)
 {
+       boost::shared_ptr<Region> 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> region)
 }
 
 void
-Session::region_renamed (boost::shared_ptr<Region> region)
-{
-       add_region (region);
-}
-
-void
-Session::remove_region (boost::shared_ptr<Region> region)
+Session::remove_region (boost::weak_ptr<Region> weak_region)
 {
        AudioRegionList::iterator i;
+       boost::shared_ptr<Region> region (weak_region.lock ());
+
+       if (!region) {
+               return;
+       }
+
        boost::shared_ptr<AudioRegion> ar;
        bool removed = false;
 
@@ -2482,7 +2495,6 @@ Session::remove_region (boost::shared_ptr<Region> region)
                        if ((i = audio_regions.find (region->id())) != audio_regions.end()) {
                                audio_regions.erase (i);
                                removed = true;
-                               cerr << "done\n";
                        }
 
                } else {
index 55a6bebb02ba1313a48543054f118e9b39bbe730..a2a340404162f143c15a40cc0784a1fab0f8f97c 100644 (file)
@@ -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
index 126bd04bba4c8d887951a7bcdea0190cd77caf51..6692ff564c742d3fb7a9109501feb2ab520b2fa2 100644 (file)
@@ -5,7 +5,7 @@
 
 namespace PBD {
 
-class Destructible {
+class Destructible : public virtual sigc::trackable {
   public:
        Destructible() {}
        virtual ~Destructible () {}