bool master_is_first = false;
uint32_t count = 0;
+ OrderingKeys sorted;
+ const size_t cmp_max = rows.size ();
+
// special case master if it's got PI order 0 lets keep it there
if (_session->master_out() && (_session->master_out()->presentation_info().order() == 0)) {
order++;
* presentation order 1
*/
if ((count == 0) && master_is_first && (stripable->presentation_info().order() == 1)) {
- master_is_first = false;
+ master_is_first = false; // someone has moved master
order = 0;
}
- if (stripable->is_master() && (master_is_first == true)) {
- continue;
+ if (stripable->is_master() && master_is_first) {
+ if (count) {
+ continue;
+ } else {
+ count++;
+ continue;
+ }
}
if (order != stripable->presentation_info().order()) {
change = true;
}
+ sorted.push_back (OrderKeys (order, stripable, cmp_max));
+
++order;
++count;
}
+ if (!change) {
+ // VCA (and Mixbus) special cases according to SortByNewDisplayOrder
+ uint32_t n = 0;
+ SortByNewDisplayOrder cmp;
+ sort (sorted.begin(), sorted.end(), cmp);
+ for (OrderingKeys::iterator sr = sorted.begin(); sr != sorted.end(); ++sr, ++n) {
+ if (sr->old_display_order != n) {
+ change = true;
+ }
+ }
+ }
+
if (change) {
DEBUG_TRACE (DEBUG::OrderKeys, "... notify PI change from editor GUI\n");
_session->notify_presentation_info_change ();
+ _session->set_dirty();
}
}
}
OrderingKeys sorted;
+ const size_t cmp_max = rows.size ();
for (TreeModel::Children::iterator ri = rows.begin(); ri != rows.end(); ++ri, ++old_order) {
boost::shared_ptr<Stripable> stripable = (*ri)[_columns.stripable];
/* use global order */
- sorted.push_back (OrderKeys (old_order, stripable->presentation_info().order()));
+ sorted.push_back (OrderKeys (old_order, stripable, cmp_max));
}
SortByNewDisplayOrder cmp;
if (changed) {
Unwinder<bool> uw (_ignore_reorder, true);
+ /* prevent traverse_cells: assertion 'row_path != NULL'
+ * in case of DnD re-order: row-removed + row-inserted.
+ *
+ * The rows (stripables) are not actually removed from the model,
+ * but only from the display in the DnDTreeView.
+ * ->reorder() will fail to find the row_path.
+ * (re-order drag -> remove row -> rync PI from TV -> notify -> sync TV from PI -> crash)
+ */
+ _display.unset_model();
_model->reorder (neworder);
+ _display.set_model (_model);
}
redisplay ();
}
_editor->add_stripables (s);
+ sync_treeview_from_presentation_info ();
}
void
DEBUG_TRACE (DEBUG::OrderKeys, string_compose ("move %1 to %2\n", leading->old_order, neworder.size() - 1));
}
#endif
-
}
+
#ifndef NDEBUG
DEBUG_TRACE (DEBUG::OrderKeys, "New order after moving tracks:\n");
for (vector<int>::iterator i = neworder.begin(); i != neworder.end(); ++i) {