summaryrefslogtreecommitdiff
path: root/gtk2_ardour/ardour_ui_startup.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2020-03-01 21:35:44 -0700
committerPaul Davis <paul@linuxaudiosystems.com>2020-03-01 21:36:07 -0700
commit8d6f6266d25ce9a0bc73b9e7a95a2f8ca17f1c9e (patch)
tree1e34c0e87c419baba6d7c333376b25899954e02c /gtk2_ardour/ardour_ui_startup.cc
parent6edccc78a2ae286cef5f992c63c04f925aa60339 (diff)
unfinished fix for handling desktop/NSM specifying session to load
More work needed to fix requirement in StartupFSM that ::load_from_application_api() is called before ::start()
Diffstat (limited to 'gtk2_ardour/ardour_ui_startup.cc')
-rw-r--r--gtk2_ardour/ardour_ui_startup.cc78
1 files changed, 78 insertions, 0 deletions
diff --git a/gtk2_ardour/ardour_ui_startup.cc b/gtk2_ardour/ardour_ui_startup.cc
index f52bbfb9f5..c555ce43da 100644
--- a/gtk2_ardour/ardour_ui_startup.cc
+++ b/gtk2_ardour/ardour_ui_startup.cc
@@ -549,6 +549,11 @@ ARDOUR_UI::startup_done ()
and we have to take over responsibility.
*/
Application::instance()->ShouldQuit.connect (sigc::mem_fun (*this, &ARDOUR_UI::queue_finish));
+ /* Same story applies for ShouldLoad ... startupFSM will handle it
+ normally, but if it doesn't we (ARDOUR_UI) need to take responsibility
+ for it.
+ */
+ Application::instance()->ShouldLoad.connect (sigc::mem_fun (*this, &ARDOUR_UI::load_from_application_api));
use_config ();
@@ -644,3 +649,76 @@ ARDOUR_UI::check_memory_locking ()
}
#endif // !__APPLE__
}
+
+void
+ARDOUR_UI::load_from_application_api (const std::string& path)
+{
+ /* OS X El Capitan (and probably later) now somehow passes the command
+ line arguments to an app via the openFile delegate protocol. Ardour
+ already does its own command line processing, and having both
+ pathways active causes crashes. So, if the command line was already
+ set, do nothing here.
+ */
+
+ if (!ARDOUR_COMMAND_LINE::session_name.empty()) {
+ return;
+ }
+
+ /* Cancel SessionDialog if it's visible to make OSX delegates work.
+ *
+ * ARDOUR_UI::starting connects app->ShouldLoad signal and then shows a SessionDialog
+ * race-condition:
+ * - ShouldLoad does not arrive in time, ARDOUR_COMMAND_LINE::session_name is empty:
+ * -> startupFSM starts a SessionDialog.
+ * - ShouldLoad signal arrives, this function is called and sets ARDOUR_COMMAND_LINE::session_name
+ * -> SessionDialog is not displayed
+ */
+
+ if (startup_fsm) {
+ startup_fsm->handle_path (path);
+ return;
+ }
+
+ ARDOUR_COMMAND_LINE::session_name = path;
+
+ int rv;
+
+ if (Glib::file_test (path, Glib::FILE_TEST_IS_DIR)) {
+ /* /path/to/foo => /path/to/foo, foo */
+ rv = load_session (path, basename_nosuffix (path));
+ } else {
+ /* /path/to/foo/foo.ardour => /path/to/foo, foo */
+ rv = load_session (Glib::path_get_dirname (path), basename_nosuffix (path));
+ }
+
+ // if load_session fails, and there is no existing session ....
+
+ if (rv && !_session) {
+
+ ARDOUR_COMMAND_LINE::session_name = string();
+
+ /* do this again */
+
+ EngineControl* amd;
+
+ try {
+ amd = dynamic_cast<EngineControl*> (audio_midi_setup.get (true));
+ } catch (...) {
+ std::cerr << "audio-midi engine setup failed."<< std::endl;
+ return;
+ }
+
+ startup_fsm = new StartupFSM (*amd);
+ startup_fsm->signal_response().connect (sigc::mem_fun (*this, &ARDOUR_UI::sfsm_response));
+
+ /* Note: entire startup process could happen in this one call
+ * if:
+ *
+ * 1) not a new user
+ * 2) session name provided on command line (and valid)
+ * 3) no audio/MIDI setup required
+ */
+
+ startup_fsm->start ();
+ }
+}