test another fix for solo-press-crashes
[ardour.git] / gtk2_ardour / editor_mixer.cc
index 8b60d73f69edb9b7d1dab5b61f2bc483461efa41..42407100f058cceab5b7b5a8fc9e8827e71bbfa5 100644 (file)
@@ -56,55 +56,56 @@ 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) {
+               return;
+       }
+
        if (yn) {
 
-               if (current_mixer_strip == 0) {
+               if (selection->tracks.empty()) {
+                       
+                       if (track_views.empty()) {      
+                               show_editor_mixer_when_tracks_arrive = true;
+                               return;
+                       } 
 
-                       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;
                                
-                               for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
-                                       AudioTimeAxisView* atv;
-
-                                       if ((atv = dynamic_cast<AudioTimeAxisView*> (*i)) != 0) {
-                                               
-                                               current_mixer_strip = new MixerStrip (*ARDOUR_UI::instance()->the_mixer(),
-                                                                                     *session,
-                                                                                     atv->route(), false);
-
-                                               current_mixer_strip->GoingAway.connect (mem_fun(*this, &Editor::cms_deleted));                                          
-                                               break;
-                                       }
+                               if ((atv = dynamic_cast<AudioTimeAxisView*> (*i)) != 0) {
+                                       r = atv->route();
+                                       break;
                                }
+                       }
 
-                       } else {
-
-                               sort_track_selection ();
-
-                               for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
-                                       AudioTimeAxisView* atv;
-
-                                       if ((atv = dynamic_cast<AudioTimeAxisView*> (*i)) != 0) {
+               } else {
 
-                                               current_mixer_strip = new MixerStrip (*ARDOUR_UI::instance()->the_mixer(),
-                                                                                     *session,
-                                                                                     atv->route(), false);
-                                               current_mixer_strip->GoingAway.connect (mem_fun(*this, &Editor::cms_deleted));                                          
-                                               break;
-                                       }
+                       sort_track_selection ();
+                       
+                       for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
+                               AudioTimeAxisView* atv;
+                               
+                               if ((atv = dynamic_cast<AudioTimeAxisView*> (*i)) != 0) {
+                                       r = atv->route();
+                                       break;
                                }
-
                        }
+               }
 
+               if (r) {
                        if (current_mixer_strip == 0) {
-                               return;
-                       }               
+                               
+                               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) {
@@ -128,6 +129,13 @@ Editor::show_editor_mixer (bool yn)
                        }
                }
        }
+
+#ifdef GTKOSX
+       /* XXX gtk problem here */
+       ruler_label_event_box.queue_draw ();
+       time_button_event_box.queue_draw ();
+       controls_layout.queue_draw ();
+#endif
 }
 
 void
@@ -151,15 +159,17 @@ Editor::set_selected_mixer_strip (TimeAxisView& view)
                if (current_mixer_strip->get_parent()) {
                        show = true;
                }
-               delete current_mixer_strip;
-               current_mixer_strip = 0;
+
+       } else {
+               
+               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 = new MixerStrip (*ARDOUR_UI::instance()->the_mixer(),
-                                             *session,
-                                             at->route(), false);
-       current_mixer_strip->GoingAway.connect (mem_fun(*this, &Editor::cms_deleted));
-       
+       current_mixer_strip->set_route (at->route());
+
        if (show) {
                show_editor_mixer (true);
        }
@@ -173,7 +183,7 @@ Editor::update_current_screen ()
 {
        if (session && session->engine().running()) {
 
-               nframes_t frame;
+               nframes64_t frame;
 
                frame = session->audible_frame();
 
@@ -185,7 +195,7 @@ Editor::update_current_screen ()
 
                if (_follow_playhead && session->requested_return_frame() < 0) {
 
-                       playhead_cursor->canvas_item.show();
+                       //playhead_cursor->canvas_item.show();
 
                        if (frame != last_update_frame) {
 
@@ -235,17 +245,12 @@ Editor::update_current_screen ()
                } else {
                        
                        if (frame != last_update_frame) {
-                               if (frame < leftmost_frame || frame > leftmost_frame + current_page_frames()) {
-                                       playhead_cursor->canvas_item.hide();
-                               } else {
-                                       playhead_cursor->set_position (frame);
-                               }
+                               playhead_cursor->set_position (frame);
                        }
                }
 
          almost_done:
                last_update_frame = frame;
-
                if (current_mixer_strip) {
                        current_mixer_strip->fast_update ();
                }
@@ -257,7 +262,7 @@ void
 Editor::current_mixer_strip_removed ()
 {
        if (current_mixer_strip) {
-               /* it is being deleted */
+               /* it is being deleted elsewhere */
                current_mixer_strip = 0;
        }
 }
@@ -287,6 +292,8 @@ Editor::current_mixer_strip_hidden ()
 void
 Editor::session_going_away ()
 {
+       _have_idled = false;
+       
        for (vector<sigc::connection>::iterator i = session_connections.begin(); i != session_connections.end(); ++i) {
                (*i).disconnect ();
        }
@@ -305,6 +312,8 @@ Editor::session_going_away ()
        drag_info.item = 0;
        last_canvas_frame = 0;
 
+       playhead_cursor->canvas_item.hide ();
+
        /* hide all tracks */
 
        hide_all_tracks (false);
@@ -333,12 +342,7 @@ Editor::session_going_away ()
        zoom_range_clock.set_session (0);
        nudge_clock.set_session (0);
 
-       /* put editor/mixer toggle button in off position and disable until a new session is loaded */
-
-       editor_mixer_button.set_active(false);
-       editor_mixer_button.set_sensitive(false);
        /* clear tempo/meter rulers */
-
        remove_metric_marks ();
        hide_measures ();
        clear_marker_display ();