From 8eb17211b5d8adab6057ff335c2050b156f91edd Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 12 Jun 2009 19:05:16 +0000 Subject: [PATCH] Hopefully fix assertion failures in gnomecanvas when dragging track heights. git-svn-id: svn://localhost/ardour2/branches/3.0@5175 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/editor.h | 2 ++ gtk2_ardour/editor_canvas.cc | 21 +++++++++++++++++++-- gtk2_ardour/editor_drag.cc | 10 +++++----- gtk2_ardour/editor_mouse.cc | 2 +- gtk2_ardour/editor_route_list.cc | 2 +- 5 files changed, 28 insertions(+), 9 deletions(-) diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index 4d212d581c..caf9b24738 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -2219,6 +2219,8 @@ public: EditorSummary* _summary; void region_view_added (RegionView *); + void update_canvas_now (); + friend class Drag; friend class RegionDrag; friend class RegionMoveDrag; diff --git a/gtk2_ardour/editor_canvas.cc b/gtk2_ardour/editor_canvas.cc index 573b3af16a..6698c5ee9b 100644 --- a/gtk2_ardour/editor_canvas.cc +++ b/gtk2_ardour/editor_canvas.cc @@ -819,7 +819,7 @@ Editor::scroll_canvas_vertically () } last_trackview_group_vertical_offset = get_trackview_group_vertical_offset (); /* required to keep the controls_layout in lock step with the canvas group */ - track_canvas->update_now (); + update_canvas_now (); } void @@ -889,8 +889,25 @@ void Editor::flush_canvas () { if (is_mapped()) { - track_canvas->update_now (); + update_canvas_now (); // gdk_window_process_updates (GTK_LAYOUT(track_canvas->gobj())->bin_window, true); } } +void +Editor::update_canvas_now () +{ + /* GnomeCanvas has a bug whereby if its idle handler is not scheduled between + two calls to update_now, an assert will trip. This wrapper works around + that problem by only calling update_now if the assert will not trip. + + I think the GC bug is due to the fact that its code will reset need_update + and need_redraw to FALSE without checking to see if an idle handler is scheduled. + If one is scheduled, GC should probably remove it. + */ + + GnomeCanvas* c = track_canvas->gobj (); + if (c->need_update || c->need_redraw) { + track_canvas->update_now (); + } +} diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index 57e554b0bd..54bc8e276d 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -798,7 +798,7 @@ RegionMoveDrag::finished (GdkEvent* event, bool movement_occurred) drag_delta = _primary->region()->position() - _last_frame_position; - _editor->track_canvas->update_now (); + _editor->update_canvas_now (); /* make a list of where each region ended up */ final = find_time_axis_views (); @@ -1066,7 +1066,7 @@ RegionMotionDrag::copy_regions (GdkEvent* event) ..only if the mouse is in rapid motion at the time of the grab. something to do with regionview creation raking so long? */ - _editor->track_canvas->update_now(); + _editor->update_canvas_now(); } bool @@ -1255,7 +1255,7 @@ RegionMotionDrag::find_time_axis_views () void RegionInsertDrag::finished (GdkEvent* event, bool movement_occurred) { - _editor->track_canvas->update_now (); + _editor->update_canvas_now (); map final = find_time_axis_views (); @@ -1893,7 +1893,7 @@ CursorDrag::motion (GdkEvent* event, bool) _editor->show_verbose_time_cursor (_cursor->current_frame, 10); #ifdef GTKOSX - _editor->track_canvas->update_now (); + _editor->update_canvas_now (); #endif _editor->UpdateAllTransportClocks (_cursor->current_frame); @@ -2355,7 +2355,7 @@ MarkerDrag::motion (GdkEvent* event, bool) _editor->show_verbose_time_cursor (newframe, 10); #ifdef GTKOSX - _editor->track_canvas->update_now (); + _editor->update_canvas_now (); #endif _editor->edit_point_clock.set (copy_location->start()); } diff --git a/gtk2_ardour/editor_mouse.cc b/gtk2_ardour/editor_mouse.cc index d29f462bd6..2eb06d4e7a 100644 --- a/gtk2_ardour/editor_mouse.cc +++ b/gtk2_ardour/editor_mouse.cc @@ -2550,7 +2550,7 @@ Editor::start_region_grab (ArdourCanvas::Item* item, GdkEvent* event, RegionView begin_reversible_command (_("move region(s)")); /* sync the canvas to what we think is its current state */ - track_canvas->update_now(); + update_canvas_now(); } void diff --git a/gtk2_ardour/editor_route_list.cc b/gtk2_ardour/editor_route_list.cc index 340f678228..17d692d8d7 100644 --- a/gtk2_ardour/editor_route_list.cc +++ b/gtk2_ardour/editor_route_list.cc @@ -158,7 +158,7 @@ Editor::handle_gui_changes (const string & what, void *src) /* Optional :make tracks change height while it happens, instead of on first-idle */ - //track_canvas->update_now (); + //update_canvas_now (); redisplay_route_list (); }