diff --git a/gtk2_ardour/editing_context.h b/gtk2_ardour/editing_context.h index 7e7a3b0826..a2d60f8551 100644 --- a/gtk2_ardour/editing_context.h +++ b/gtk2_ardour/editing_context.h @@ -342,6 +342,15 @@ class EditingContext : public ARDOUR::SessionHandlePtr, public AxisViewProvider /** Push the appropriate enter/cursor context on item entry. */ void choose_canvas_cursor_on_entry (ItemType); + struct CursorRAII { + CursorRAII (EditingContext& e, Gdk::Cursor* new_cursor) + : ec (e), old_cursor (ec.get_canvas_cursor ()) { ec.set_canvas_cursor (new_cursor); } + ~CursorRAII () { ec.set_canvas_cursor (old_cursor); } + + EditingContext& ec; + Gdk::Cursor* old_cursor; + }; + virtual Gdk::Cursor* get_canvas_cursor () const; static MouseCursors const* cursors () { return _cursors; diff --git a/gtk2_ardour/editor_audio_import.cc b/gtk2_ardour/editor_audio_import.cc index 65cc38134d..702ba3550b 100644 --- a/gtk2_ardour/editor_audio_import.cc +++ b/gtk2_ardour/editor_audio_import.cc @@ -574,7 +574,7 @@ Editor::import_sndfiles (vector paths, import_status.track = track; import_status.replace = replace; - set_canvas_cursor (_cursors->wait); + CursorRAII cr (*this, _cursors->wait); /* start import thread for this spec. this will ultimately call Session::import_files() which, if successful, will add the files as regions to the region list. its up to us @@ -636,7 +636,7 @@ Editor::embed_sndfiles (vector paths, /* skip periodic saves while importing */ Session::StateProtector sp (_session); - set_canvas_cursor (_cursors->wait); + CursorRAII cr (*this, _cursors->wait); for (vector::iterator p = paths.begin(); p != paths.end(); ++p) { diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index a9ca4ed1fe..e965cad850 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -4379,7 +4379,7 @@ Editor::freeze_route () pthread_create_and_store (X_("freezer"), &itt.thread, _freeze_thread, this, 0); - set_canvas_cursor (_cursors->wait); + CursorRAII cr (*this, _cursors->wait); while (!itt.done && !itt.cancel) { gtk_main_iteration (); @@ -5921,7 +5921,7 @@ Editor::normalize_region () return; } - set_canvas_cursor (_cursors->wait); + CursorRAII cr (*this, _cursors->wait); /* XXX: should really only count audio regions here */ int const regions = rs.size (); @@ -6200,7 +6200,7 @@ Editor::fork_regions_from_unselected () return; } - set_canvas_cursor (_cursors->wait); + CursorRAII cr (*this, _cursors->wait); bool in_command = false; /* find the set of all MidiSources associated with the selected regions */ @@ -6278,7 +6278,7 @@ Editor::fork_selected_regions () return; } - set_canvas_cursor (_cursors->wait); + CursorRAII cr (*this, _cursors->wait); bool in_command = false; for (RegionSelection::iterator r = rs.begin(); r != rs.end(); ) { @@ -6360,7 +6360,7 @@ Editor::apply_filter (Filter& filter, string command, ProgressReporter* progress return; } - set_canvas_cursor (_cursors->wait); + CursorRAII cr (*this, _cursors->wait); bool in_command = false; int n = 0;