diff options
Diffstat (limited to 'gtk2_ardour/ardour_ui.cc')
-rw-r--r-- | gtk2_ardour/ardour_ui.cc | 43 |
1 files changed, 37 insertions, 6 deletions
diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc index 74234bb12a..ca0506878e 100644 --- a/gtk2_ardour/ardour_ui.cc +++ b/gtk2_ardour/ardour_ui.cc @@ -947,9 +947,30 @@ ARDOUR_UI::filter_ardour_session_dirs (const FileFilter::Info& info) return S_ISREG (statbuf.st_mode); } +bool +ARDOUR_UI::check_audioengine () +{ + if (engine) { + if (!engine->connected()) { + MessageDialog msg (_("Ardour is not connected to JACK\n" + "You cannot open or close sessions in this condition")); + msg.run (); + return false; + } + return true; + } else { + return false; + } +} + void ARDOUR_UI::open_session () { + if (!check_audioengine()) { + return; + + } + /* popup selector window */ if (open_session_selector == 0) { @@ -1751,9 +1772,7 @@ ARDOUR_UI::new_session (std::string predetermined_path) string session_name; string session_path; - if (!engine->connected()) { - MessageDialog msg (_("Ardour is not connected to JACK at this time. Creating new sessions is not possible.")); - msg.run (); + if (!check_audioengine()) { return false; } @@ -1768,10 +1787,8 @@ ARDOUR_UI::new_session (std::string predetermined_path) do { response = new_session_dialog->run (); - if (!engine->connected()) { + if (!check_audioengine()) { new_session_dialog->hide (); - MessageDialog msg (_("Ardour is not connected to JACK at this time. Creating new sessions is not possible.")); - msg.run (); return false; } @@ -1964,6 +1981,10 @@ ARDOUR_UI::new_session (std::string predetermined_path) void ARDOUR_UI::close_session() { + if (!check_audioengine()) { + return; + } + unload_session(); new_session (); } @@ -1975,6 +1996,10 @@ ARDOUR_UI::load_session (const string & path, const string & snap_name, string* int x; session_loaded = false; + if (!check_audioengine()) { + return -1; + } + x = unload_session (); if (x < 0) { @@ -2031,8 +2056,14 @@ ARDOUR_UI::build_session (const string & path, const string & snap_name, Session *new_session; int x; + if (!check_audioengine()) { + return -1; + } + session_loaded = false; + x = unload_session (); + if (x < 0) { return -1; } else if (x > 0) { |