diff --git a/libs/pbd/epa.cc b/libs/pbd/epa.cc index 3d3f7477d7..2d5ec29506 100644 --- a/libs/pbd/epa.cc +++ b/libs/pbd/epa.cc @@ -115,7 +115,29 @@ EnvironmentalProtectionAgency::save () void EnvironmentalProtectionAgency::restore () const { + clear (); + for (map::const_iterator i = e.begin(); i != e.end(); ++i) { setenv (i->first.c_str(), i->second.c_str(), 1); } -} +} + +void +EnvironmentalProtectionAgency::clear () const +{ + char** the_environ = environ; + + for (size_t i = 0; the_environ[i]; ++i) { + + string estring = the_environ[i]; + string::size_type equal = estring.find_first_of ('='); + + if (equal == string::npos) { + /* say what? an environ value without = ? */ + continue; + } + + string before = estring.substr (0, equal); + unsetenv(before.c_str()); + } +} diff --git a/libs/pbd/openuri.cc b/libs/pbd/openuri.cc index 403aff07c7..22e9bee715 100644 --- a/libs/pbd/openuri.cc +++ b/libs/pbd/openuri.cc @@ -10,20 +10,27 @@ bool PBD::open_uri (const char* uri) { -#ifdef HAVE_GTK_OPEN_URI - GError* err; - return gtk_open_uri (0, uri, GDK_CURRENT_TIME, &err); -#else #ifdef __APPLE__ extern bool cocoa_open_url (const char*); return cocoa_open_url (uri); #else + EnvironmentalProtectionAgency* global_epa = EnvironmentalProtectionAgency::get_global_epa (); + boost::scoped_ptr current_epa; + + /* revert all environment settings back to whatever they were when ardour started + */ + + if (global_epa) { + current_epa.reset (new EnvironmentalProtectionAgency(true)); /* will restore settings when we leave scope */ + global_epa->restore (); + } + std::string command = "xdg-open "; command += uri; - Glib::spawn_command_line_async (command); + command += " &"; + system (command.c_str()); return true; #endif -#endif } diff --git a/libs/pbd/pbd/epa.h b/libs/pbd/pbd/epa.h index ffcd78504a..477d7f9678 100644 --- a/libs/pbd/pbd/epa.h +++ b/libs/pbd/pbd/epa.h @@ -38,6 +38,8 @@ class EnvironmentalProtectionAgency { static void set_global_epa (EnvironmentalProtectionAgency* epa) { _global_epa = epa; } private: + void clear () const; + bool _armed; std::string _envname; std::map e;