track combine ops per-playlist to avoid name collisions for compound regions
authorPaul Davis <paul@linuxaudiosystems.com>
Mon, 16 May 2011 21:21:16 +0000 (21:21 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Mon, 16 May 2011 21:21:16 +0000 (21:21 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@9529 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/ardour.menus.in
gtk2_ardour/route_time_axis.cc
libs/ardour/ardour/playlist.h
libs/ardour/playlist.cc

index d59fcc8f385217f068e8fadcc510828548c734ad..e6e4d1328fa46df3d563a9f9602d967b7e730fc8 100644 (file)
     <menuitem action='pitch-shift-region'/>
     <menuitem action='transpose-region'/>
     <menuitem action='naturalize-region'/>
+    <menuitem action='combine-regions'/>
     <menuitem action='split-region'/>
     <menuitem action='split-multichannel-region'/>
     <menuitem action='remove-region'/>
index 119f1814d3b127886394649d71f8d238082a25ab..9f6a5e69ffbc23755b6ab54b173bd569c28d0fb9 100644 (file)
@@ -2500,9 +2500,7 @@ RouteTimeAxisView::combine_regions ()
 
        _view->foreach_selected_regionview (sigc::bind (sigc::ptr_fun (add_region_to_list), &selected_regions, &max_level));
        
-       uint32_t num_joined_regions = playlist->count_joined_regions();
-       string name = string_compose (_("%1 compound-%2 (%3)"), playlist->name(), num_joined_regions+1, max_level+1);
-
+       string name = string_compose (_("%1 compound-%2 (%3)"), playlist->name(), playlist->combine_ops()+1, max_level+1);
 
        playlist->clear_changes ();
        playlist->join (selected_regions, name);
index 72155d99810be3a2421913ac6474377333e77ef9..7411468fe8b4b5cb5f25e18fdb30f4d674f95da4 100644 (file)
@@ -229,6 +229,7 @@ public:
        }
 
        framepos_t find_next_top_layer_position (framepos_t) const;     
+       uint32_t combine_ops() const { return _combine_ops; }
 
   protected:
        friend class Session;
@@ -295,6 +296,7 @@ public:
        uint64_t         layer_op_counter;
        framecnt_t       freeze_length;
        bool             auto_partition;
+       uint32_t        _combine_ops;
 
        /** true if relayering should be done using region's current layers and their `pending explicit relayer'
         *  flags; otherwise false if relayering should be done using the layer-model (most recently moved etc.)
index 9ceb11fe51efa64bc7185b14dc40657633ebaac8..d933594d3da1b165f0839060911322cc32a42b1b 100644 (file)
 
 #include <boost/lexical_cast.hpp>
 
+#include "pbd/convert.h"
 #include "pbd/failed_constructor.h"
 #include "pbd/stateful_diff_command.h"
 #include "pbd/xml++.h"
-#include "pbd/stacktrace.h"
 
 #include "ardour/debug.h"
 #include "ardour/playlist.h"
@@ -357,6 +357,7 @@ Playlist::init (bool hide)
        layer_op_counter = 0;
        freeze_length = 0;
        _explicit_relayering = false;
+       _combine_ops = 0;
 
        _session.history().BeginUndoRedo.connect_same_thread (*this, boost::bind (&Playlist::begin_undo, this));
        _session.history().EndUndoRedo.connect_same_thread (*this, boost::bind (&Playlist::end_undo, this));
@@ -2277,6 +2278,8 @@ Playlist::set_state (const XMLNode& node, int version)
                        _orig_diskstream_id = prop->value ();
                } else if (prop->name() == X_("frozen")) {
                        _frozen = string_is_affirmative (prop->value());
+               } else if (prop->name() == X_("combine-ops")) {
+                       _combine_ops = atoi (prop->value());
                }
        }
 
@@ -2369,7 +2372,7 @@ XMLNode&
 Playlist::state (bool full_state)
 {
        XMLNode *node = new XMLNode (X_("Playlist"));
-       char buf[64] = "";
+       char buf[64];
 
        node->add_property (X_("id"), id().to_s());
        node->add_property (X_("name"), _name);
@@ -2383,6 +2386,9 @@ Playlist::state (bool full_state)
                RegionLock rlock (this, false);
                XMLNode* nested_node = 0;
 
+               snprintf (buf, sizeof (buf), "%u", _combine_ops);
+               node->add_property ("combine-ops", buf);
+
                for (RegionList::iterator i = regions.begin(); i != regions.end(); ++i) {
                        if ((*i)->max_source_level() > 0) {
 
@@ -3208,6 +3214,7 @@ Playlist::join (const RegionList& r, const std::string& name)
        /* add the new region at the right location */
        
        add_region (compound_region, earliest_position);
+       _combine_ops++;
 
        thaw ();
 }