test another fix for solo-press-crashes
[ardour.git] / gtk2_ardour / editor_mixer.cc
index 81b79965b970d1ae4b8ebfb26cbdbd3bd0ab8707..42407100f058cceab5b7b5a8fc9e8827e71bbfa5 100644 (file)
@@ -56,6 +56,8 @@ Editor::cms_deleted ()
 void
 Editor::show_editor_mixer (bool yn)
 {
+       boost::shared_ptr<ARDOUR::Route> r;
+
        show_editor_mixer_when_tracks_arrive = false;
 
        if (!session) {
@@ -64,27 +66,18 @@ Editor::show_editor_mixer (bool yn)
 
        if (yn) {
 
-               if (current_mixer_strip == 0) {
-
-                       current_mixer_strip = new MixerStrip (*ARDOUR_UI::instance()->the_mixer(),
-                                                             *session,
-                                                             false);
-                       current_mixer_strip->GoingAway.connect (mem_fun(*this, &Editor::cms_deleted));                                          
-               }
-
-               
                if (selection->tracks.empty()) {
                        
                        if (track_views.empty()) {      
                                show_editor_mixer_when_tracks_arrive = true;
                                return;
                        } 
-                       
+
                        for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
                                AudioTimeAxisView* atv;
                                
                                if ((atv = dynamic_cast<AudioTimeAxisView*> (*i)) != 0) {
-                                       current_mixer_strip->set_route (atv->route());
+                                       r = atv->route();
                                        break;
                                }
                        }
@@ -97,11 +90,23 @@ Editor::show_editor_mixer (bool yn)
                                AudioTimeAxisView* atv;
                                
                                if ((atv = dynamic_cast<AudioTimeAxisView*> (*i)) != 0) {
-                                       current_mixer_strip->set_route (atv->route());
+                                       r = atv->route();
                                        break;
                                }
                        }
                }
+
+               if (r) {
+                       if (current_mixer_strip == 0) {
+                               
+                               current_mixer_strip = new MixerStrip (*ARDOUR_UI::instance()->the_mixer(),
+                                                                     *session,
+                                                                     false);
+                               current_mixer_strip->GoingAway.connect (mem_fun(*this, &Editor::cms_deleted));                                          
+                       }
+                       
+                       current_mixer_strip->set_route (r);
+               }
                
                if (current_mixer_strip->get_parent() == 0) {
                        current_mixer_strip->set_embedded (true);
@@ -137,6 +142,7 @@ void
 Editor::set_selected_mixer_strip (TimeAxisView& view)
 {
        AudioTimeAxisView* at;
+       bool show = false;
 
        if (!session || (at = dynamic_cast<AudioTimeAxisView*>(&view)) == 0) {
                return;
@@ -150,6 +156,10 @@ Editor::set_selected_mixer_strip (TimeAxisView& view)
                        return;
                }
 
+               if (current_mixer_strip->get_parent()) {
+                       show = true;
+               }
+
        } else {
                
                current_mixer_strip = new MixerStrip (*ARDOUR_UI::instance()->the_mixer(),
@@ -159,7 +169,10 @@ Editor::set_selected_mixer_strip (TimeAxisView& view)
        }
 
        current_mixer_strip->set_route (at->route());
-       show_editor_mixer (true);
+
+       if (show) {
+               show_editor_mixer (true);
+       }
 }
 
 double current = 0.0;