[Summary] Optimized Tracks removing/adding but redundant actions cut off
authorGZharun <grygoriiz@wavesglobal.com>
Thu, 16 Oct 2014 08:57:09 +0000 (11:57 +0300)
committerGZharun <grygoriiz@wavesglobal.com>
Thu, 16 Oct 2014 08:57:09 +0000 (11:57 +0300)
libs/ardour/ardour/session.h
libs/ardour/session.cc

index 8195359906f52f6e4609bd67893b7844756df31d..10a3d208f9a3a2a46aac2a006307fb4bfe80fd57 100644 (file)
@@ -184,6 +184,7 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop
        void clear_deletion_in_progress ();
        bool deletion_in_progress() const { return _state_of_the_state & Deletion; }
     bool reconnection_in_progress() const { return _reconnecting_routes_in_progress; }
+    bool routes_deletion_in_progress() const { return _route_deletion_in_progress; }
        PBD::Signal0<void> DirtyChanged;
 
        const SessionDirectory& session_directory () const { return *(_session_dir.get()); }
@@ -1384,6 +1385,7 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop
         void add_routes_inner (RouteList&, bool input_auto_connect, bool output_auto_connect);
         bool _adding_routes_in_progress;
     bool _reconnecting_routes_in_progress;
+    bool _route_deletion_in_progress;
 
        uint32_t destructive_index;
 
index 4f77545d536f66c4050457d758b9f0a70bd2cdad..b2a8c8211ee9d04cc928c232a2f3ae2df03f5402 100644 (file)
@@ -2294,6 +2294,11 @@ Session::auto_connect_route (boost::shared_ptr<Route> route, ChanCount& existing
 void
 Session::reconnect_existing_routes (bool withLock, bool reconnect_master, bool reconnect_inputs, bool reconnect_outputs)
 {
+    // if we are deleting routes we will call this once at the end
+    if (_route_deletion_in_progress) {
+        return;
+    }
+    
     Glib::Threads::Mutex::Lock lm (AudioEngine::instance()->process_lock (), Glib::Threads::NOT_LOCK);
     
        if (withLock) {
@@ -2947,7 +2952,8 @@ Session::add_routes_inner (RouteList& new_routes, bool input_auto_connect, bool
                }
         
                if (input_auto_connect || output_auto_connect) {
-                       auto_connect_route (r, existing_inputs, existing_outputs, true, input_auto_connect);
+                       // routes will be connected later
+            //auto_connect_route (r, existing_inputs, existing_outputs, true, input_auto_connect);
                }
 
                /* order keys are a GUI responsibility but we need to set up
@@ -3169,6 +3175,7 @@ Session::remove_routes (boost::shared_ptr<RouteList> routes_to_remove)
     /* try to cause everyone to drop their references
      * and unregister ports from the backend
      */
+    PBD::Unwinder<bool> uw_flag (_route_deletion_in_progress, true);
     for (RouteList::iterator iter = routes_to_remove->begin(); iter != routes_to_remove->end(); ++iter) {
         
         (*iter)->drop_references ();