minor cleanups from 12952
[ardour.git] / gtk2_ardour / editor.cc
index a08b9f8e5f0e57a09fb55c33982d3d6729b64561..4cc4f6b6d6ce1d3627aa9549314b0b946d0ee9f5 100644 (file)
@@ -1271,7 +1271,7 @@ Editor::set_session (Session *t)
        _session->StepEditStatusChange.connect (_session_connections, invalidator (*this), boost::bind (&Editor::step_edit_status_change, this, _1), gui_context());
        _session->TransportStateChange.connect (_session_connections, invalidator (*this), boost::bind (&Editor::map_transport_state, this), gui_context());
        _session->PositionChanged.connect (_session_connections, invalidator (*this), boost::bind (&Editor::map_position_change, this, _1), gui_context());
-       _session->RouteAdded.connect (_session_connections, invalidator (*this), boost::bind (&Editor::handle_new_route, this, _1), gui_context());
+       _session->RouteAdded.connect (_session_connections, invalidator (*this), boost::bind (&Editor::add_routes, this, _1), gui_context());
        _session->DirtyChanged.connect (_session_connections, invalidator (*this), boost::bind (&Editor::update_title, this), gui_context());
        _session->tempo_map().PropertyChanged.connect (_session_connections, invalidator (*this), boost::bind (&Editor::tempo_map_changed, this, _1), gui_context());
        _session->Located.connect (_session_connections, invalidator (*this), boost::bind (&Editor::located, this), gui_context());
@@ -4241,6 +4241,18 @@ Editor::_idle_visual_changer (void* arg)
 int
 Editor::idle_visual_changer ()
 {
+       /* set_horizontal_position() below (and maybe other calls) call
+          gtk_main_iteration(), so it's possible that a signal will be handled
+          half-way through this method.  If this signal wants an
+          idle_visual_changer we must schedule another one after this one, so
+          mark the idle_handler_id as -1 here to allow that.  Also make a note
+          that we are doing the visual change, so that changes in response to
+          super-rapid-screen-update can be dropped if we are still processing
+          the last one.
+       */
+       pending_visual_change.idle_handler_id = -1;
+       pending_visual_change.being_handled = true;
+       
        VisualChange::Type p = pending_visual_change.pending;
        pending_visual_change.pending = (VisualChange::Type) 0;
 
@@ -4269,7 +4281,7 @@ Editor::idle_visual_changer ()
 
        _summary->set_overlays_dirty ();
 
-       pending_visual_change.idle_handler_id = -1;
+       pending_visual_change.being_handled = false;
        return 0; /* this is always a one-shot call */
 }
 
@@ -4773,9 +4785,8 @@ Editor::axis_views_from_routes (boost::shared_ptr<RouteList> r) const
        return t;
 }
 
-
 void
-Editor::handle_new_route (RouteList& routes)
+Editor::add_routes (RouteList& routes)
 {
        ENSURE_GUI_THREAD (*this, &Editor::handle_new_route, routes)
 
@@ -5191,7 +5202,14 @@ Editor::super_rapid_screen_update ()
 
                if (!_stationary_playhead) {
 
-                       if (!_dragging_playhead && _follow_playhead && _session->requested_return_frame() < 0) {
+                       if (!_dragging_playhead && _follow_playhead && _session->requested_return_frame() < 0 && !pending_visual_change.being_handled) {
+                               /* We only do this if we aren't already
+                                  handling a visual change (ie if
+                                  pending_visual_change.being_handled is
+                                  false) so that these requests don't stack
+                                  up there are too many of them to handle in
+                                  time.
+                               */
                                reset_x_origin_to_follow_playhead ();
                        }