Fix crash when X11 is not available for VST UIs
[ardour.git] / gtk2_ardour / nsm.cc
index e3ceba355f1f1c89b765f279718ac3c2f247a96b..1f2aa5a5dae855a273a605a7c13b9a34026de397 100644 (file)
 /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 /*******************************************************************************/
 
+#include <stdio.h>
+#include <unistd.h>
+
+#include "gtkmm2ext/application.h"
 
 #include "nsm.h"
 #include "opts.h"
 #include "ardour_ui.h"
 
-#include <stdio.h>
-#include <unistd.h>
-
-
 NSM_Client::NSM_Client()
 {
 }
@@ -33,12 +33,12 @@ NSM_Client::NSM_Client()
 int
 NSM_Client::command_save(char **out_msg)
 {
-    (void) out_msg;
+       (void) out_msg;
 
-    ARDOUR_UI::instance()->save_state();
-    int r = ERR_OK;
+       ARDOUR_UI::instance()->save_state();
+       int r = ERR_OK;
 
-    return r;
+       return r;
 }
 
 int
@@ -47,13 +47,15 @@ NSM_Client::command_open(const char* name,
                          const char* client_id,
                          char** /*out_msg*/)
 {
-    int r = ERR_OK;
+       int r = ERR_OK;
+
+       ARDOUR_COMMAND_LINE::backend_client_name = client_id;
+
+       /* this appears asynchronous, but almost certainly is
+       synchronous. However, there's no return value available.
+       */
 
-    ARDOUR_COMMAND_LINE::session_name = name;
-    ARDOUR_COMMAND_LINE::backend_client_name = client_id;
+       Gtkmm2ext::Application::instance()->ShouldLoad (name);
 
-    if (ARDOUR_UI::instance()->get_session_parameters(true, false, "")) {
-        return ERR_GENERAL;
-    }
-    return r;
+       return r;
 }