Remove special handling of session range in export. Fixes things when the session...
authorSakari Bergen <sakari.bergen@beatwaves.net>
Sun, 26 May 2013 17:25:27 +0000 (20:25 +0300)
committerSakari Bergen <sakari.bergen@beatwaves.net>
Sun, 26 May 2013 17:25:27 +0000 (20:25 +0300)
gtk2_ardour/export_timespan_selector.cc
libs/ardour/ardour/export_profile_manager.h
libs/ardour/export_profile_manager.cc

index a96ea69b6d6f0c9ddbb3fd38299945c66188b59f..f239ab194ba2533f10e3bd00bd0b106f114aefa0 100644 (file)
@@ -120,9 +120,7 @@ ExportTimespanSelector::add_range_to_selection (ARDOUR::Location const * loc)
        ExportTimespanPtr span = _session->get_export_handler()->add_timespan();
 
        std::string id;
-       if (loc == state->session_range.get()) {
-               id = "session";
-       } else if (loc == state->selection_range.get()) {
+       if (loc == state->selection_range.get()) {
                id = "selection";
        } else {
                id = loc->id().to_s();
@@ -367,9 +365,7 @@ ExportTimespanSelectorSingle::fill_range_list ()
        if (!state) { return; }
 
        std::string id;
-       if (!range_id.compare (X_("session"))) {
-               id = state->session_range->id().to_s();
-       } else if (!range_id.compare (X_("selection"))) {
+       if (!range_id.compare (X_("selection"))) {
                id = state->selection_range->id().to_s();
        } else {
                id = range_id;
@@ -459,9 +455,8 @@ ExportTimespanSelectorMultiple::set_selection_from_state ()
                for (tree_it = range_list->children().begin(); tree_it != range_list->children().end(); ++tree_it) {
                        Location * loc = tree_it->get_value (range_cols.location);
 
-                       if ((!id.compare ("session") && loc == state->session_range.get()) ||
-                           (!id.compare ("selection") && loc == state->selection_range.get()) ||
-                           (!id.compare (loc->id().to_s()))) {
+                       if ((id == "selection" && loc == state->selection_range.get()) ||
+                           (id == loc->id().to_s())) {
                                tree_it->set_value (range_cols.selected, true);
                        }
                }
index 82b32fb032a8939fc8b04058d8cadf0d83647051..424e0fe163c7b0f552b5bd3aee520f5ecbfa6f12 100644 (file)
@@ -122,16 +122,13 @@ class ExportProfileManager
                TimespanListPtr timespans;
                TimeFormat      time_format;
 
-               boost::shared_ptr<Location> session_range;
                boost::shared_ptr<Location> selection_range;
                boost::shared_ptr<LocationList> ranges;
 
-               TimespanState (boost::shared_ptr<Location> session_range,
-                              boost::shared_ptr<Location> selection_range,
+               TimespanState (boost::shared_ptr<Location> selection_range,
                               boost::shared_ptr<LocationList> ranges)
                  : timespans (new TimespanList ())
                  , time_format (Timecode)
-                 , session_range (session_range)
                  , selection_range (selection_range)
                  , ranges (ranges)
                {}
@@ -157,7 +154,6 @@ class ExportProfileManager
 
        void update_ranges ();
 
-       boost::shared_ptr<Location>     session_range;
        boost::shared_ptr<Location>     selection_range;
        boost::shared_ptr<LocationList> ranges;
 
index 388ffe25081789bd04ec37fa6af5e2a2ad507ee6..bc4b31e3244501ba8fc233faac52d017ccefe59a 100644 (file)
@@ -61,7 +61,6 @@ ExportProfileManager::ExportProfileManager (Session & s, ExportType type)
   , handler (s.get_export_handler())
   , session (s)
 
-  , session_range (new Location (s))
   , ranges (new LocationList ())
   , single_range_mode (false)
 
@@ -385,13 +384,16 @@ ExportProfileManager::init_timespans (XMLNodeList nodes)
        }
 
        if (timespans.empty()) {
-               TimespanStatePtr state (new TimespanState (session_range, selection_range, ranges));
+               TimespanStatePtr state (new TimespanState (selection_range, ranges));
                timespans.push_back (state);
 
                // Add session as default selection
+               Location * session_range = session.locations()->session_range_location();
+               if (!session_range) { return false; }
+
                ExportTimespanPtr timespan = handler->add_timespan();
                timespan->set_name (session_range->name());
-               timespan->set_range_id ("session");
+               timespan->set_range_id (session_range->id().to_s());
                timespan->set_range (session_range->start(), session_range->end());
                state->timespans->push_back (timespan);
                return false;
@@ -403,7 +405,7 @@ ExportProfileManager::init_timespans (XMLNodeList nodes)
 ExportProfileManager::TimespanStatePtr
 ExportProfileManager::deserialize_timespan (XMLNode & root)
 {
-       TimespanStatePtr state (new TimespanState (session_range, selection_range, ranges));
+       TimespanStatePtr state (new TimespanState (selection_range, ranges));
        XMLProperty const * prop;
 
        XMLNodeList spans = root.children ("Range");
@@ -413,17 +415,22 @@ ExportProfileManager::deserialize_timespan (XMLNode & root)
                if (!prop) { continue; }
                string id = prop->value();
 
+               Location * location = 0;
                for (LocationList::iterator it = ranges->begin(); it != ranges->end(); ++it) {
-                       if ((!id.compare ("session") && *it == session_range.get()) ||
-                           (!id.compare ("selection") && *it == selection_range.get()) ||
-                           (!id.compare ((*it)->id().to_s()))) {
-                               ExportTimespanPtr timespan = handler->add_timespan();
-                               timespan->set_name ((*it)->name());
-                               timespan->set_range_id (id);
-                               timespan->set_range ((*it)->start(), (*it)->end());
-                               state->timespans->push_back (timespan);
+                       if ((id == "selection" && *it == selection_range.get()) ||
+                           (id == (*it)->id().to_s())) {
+                               location = *it;
+                               break;
                        }
                }
+
+               if (!location) { continue; }
+
+               ExportTimespanPtr timespan = handler->add_timespan();
+               timespan->set_name (location->name());
+               timespan->set_range_id (location->id().to_s());
+               timespan->set_range (location->start(), location->end());
+               state->timespans->push_back (timespan);
        }
 
        if ((prop = root.property ("format"))) {
@@ -440,7 +447,6 @@ ExportProfileManager::serialize_timespan (TimespanStatePtr state)
        XMLNode * span;
 
        update_ranges ();
-
        for (TimespanList::iterator it = state->timespans->begin(); it != state->timespans->end(); ++it) {
                if ((span = root.add_child ("Range"))) {
                        span->add_property ("id", (*it)->range_id());
@@ -463,9 +469,10 @@ ExportProfileManager::update_ranges () {
 
        /* Session */
 
-       session_range->set_name (_("Session"));
-       session_range->set (session.current_start_frame(), session.current_end_frame());
-       ranges->push_back (session_range.get());
+       Location * session_range = session.locations()->session_range_location();
+       if (session_range) {
+               ranges->push_back (session_range);
+       }
 
        /* Selection */