try to keep editor+mixer treemodels in sync
[ardour.git] / gtk2_ardour / mixer_ui.cc
index ef3228375a28d6b6b23a42b6f39019d072e0fdf4..196a53647ada2c13ffbfdbbfff2da714c6b1db22 100644 (file)
@@ -64,6 +64,7 @@
 #include "actions.h"
 #include "gui_thread.h"
 #include "mixer_group_tabs.h"
+#include "route_sorter.h"
 #include "timers.h"
 #include "ui_config.h"
 #include "vca_master_strip.h"
@@ -479,8 +480,11 @@ void
 Mixer_UI::add_stripables (StripableList& slist)
 {
        Gtk::TreeModel::Children::iterator insert_iter = track_model->children().end();
+       bool from_scratch = (track_model->children().size() == 0);
        uint32_t nroutes = 0;
 
+       slist.sort (StripablePresentationInfoSorter());
+
        for (Gtk::TreeModel::Children::iterator it = track_model->children().begin(); it != track_model->children().end(); ++it) {
                boost::shared_ptr<Stripable> s = (*it)[stripable_columns.stripable];
 
@@ -589,8 +593,9 @@ Mixer_UI::add_stripables (StripableList& slist)
        no_track_list_redisplay = false;
        track_display.set_model (track_model);
 
-       sync_presentation_info_from_treeview ();
-       redisplay_track_list ();
+       if (!from_scratch) {
+               sync_presentation_info_from_treeview ();
+       }
 }
 
 void
@@ -687,6 +692,10 @@ Mixer_UI::sync_presentation_info_from_treeview ()
                        continue;
                }
 
+               /* Master also doesn't get set here but since the editor allows
+                * it to be reordered, we need to preserve its ordering.
+                */
+
                stripable->presentation_info().set_hidden (!visible);
 
                if (order != stripable->presentation_info().order()) {