Plugin automation fixes from torbenh.
[ardour.git] / gtk2_ardour / main.cc
index dd4bcab9195d94c03259f87d7b5dd15d22ad5578..edbdcd58cb747911140ffb4a3299127721b8a7a3 100644 (file)
@@ -18,6 +18,7 @@
 */
 
 #include <cstdlib>
+#include <signal.h>
 
 #include <sigc++/bind.h>
 #include <gtkmm/settings.h>
@@ -30,6 +31,7 @@
 
 #include <jack/jack.h>
 
+#include <ardour/svn_revision.h>
 #include <ardour/version.h>
 #include <ardour/ardour.h>
 #include <ardour/audioengine.h>
@@ -40,7 +42,6 @@
 #include <gtkmm2ext/popup.h>
 #include <gtkmm2ext/utils.h>
 
-#include "../svn_revision.h"
 #include "version.h"
 #include "utils.h"
 #include "ardour_ui.h"
@@ -205,6 +206,13 @@ fixup_bundle_environment ()
           actually exists ...
        */
 
+       try {
+               sys::create_directories (user_config_directory ());
+       }
+       catch (const sys::filesystem_error& ex) {
+               error << _("Could not create user configuration directory") << endmsg;
+       }
+       
        sys::path pangopath = user_config_directory();
        pangopath /= "pango.rc";
        path = pangopath.to_string();
@@ -212,6 +220,7 @@ fixup_bundle_environment ()
        std::ofstream pangorc (path.c_str());
        if (!pangorc) {
                error << string_compose (_("cannot open pango.rc file %1") , path) << endmsg;
+               return;
        } else {
                pangorc << "[Pango]\nModuleFiles=";
 
@@ -221,6 +230,7 @@ fixup_bundle_environment ()
                pangopath /= "pango.modules";
                        
                pangorc << pangopath.to_string() << endl;
+
                pangorc.close ();
 
                setenv ("PANGO_RC_FILE", path.c_str(), 1);
@@ -243,6 +253,7 @@ fixup_bundle_environment ()
        path += "/../Resources/gdk-pixbuf.loaders";
 
        setenv ("GDK_PIXBUF_MODULE_FILE", path.c_str(), 1);
+       cerr << "Set GDK_PIXBUF_MODULE_FILE to " << path << endl;
 
        if (getenv ("ARDOUR_WITH_JACK")) {
                // JACK driver dir
@@ -256,6 +267,12 @@ fixup_bundle_environment ()
 
 #endif
 
+static void
+sigpipe_handler (int sig)
+{
+       cerr << _("SIGPIPE received - JACK has probably died") << endl;
+}
+
 #ifdef VST_SUPPORT
 /* this is called from the entry point of a wine-compiled
    executable that is linked against gtk2_ardour built
@@ -269,9 +286,12 @@ int main (int argc, char *argv[])
 {
        vector<Glib::ustring> null_file_list;
        
+       cerr << "here we go\n";
+       
 #ifdef __APPLE__
        fixup_bundle_environment ();
 #endif
+       cerr << "just did it\n";
 
         Glib::thread_init();
        gtk_set_locale ();
@@ -304,7 +324,7 @@ int main (int argc, char *argv[])
        cout << _("Ardour/GTK ") 
             << VERSIONSTRING
             << _("\n   (built using ")
-            << ardour_svn_revision
+            << svn_revision
 #ifdef __GNUC__
             << _(" and GCC version ") << __VERSION__ 
 #endif
@@ -330,6 +350,10 @@ int main (int argc, char *argv[])
 
        PBD::ID::init ();
 
+       if (::signal (SIGPIPE, sigpipe_handler)) {
+               cerr << _("Cannot install SIGPIPE error handler") << endl;
+       }
+
         try { 
                ui = new ARDOUR_UI (&argc, &argv);
        } catch (failed_constructor& err) {