From b000568d4942ae1bcd3bdb2878714efce7af603e Mon Sep 17 00:00:00 2001 From: Leland Lucius Date: Wed, 10 Jun 2015 21:59:02 -0500 Subject: [PATCH] Fix for bug #1023 --- src/effects/ladspa/LadspaEffect.cpp | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/effects/ladspa/LadspaEffect.cpp b/src/effects/ladspa/LadspaEffect.cpp index 403275a15..2e979595e 100644 --- a/src/effects/ladspa/LadspaEffect.cpp +++ b/src/effects/ladspa/LadspaEffect.cpp @@ -208,11 +208,12 @@ bool LadspaEffectsModule::RegisterPlugin(PluginManagerInterface & pm, const wxSt // As a courtesy to some plug-ins that might be bridges to // open other plug-ins, we set the current working // directory to be the plug-in's directory. - - wxString saveOldCWD = ::wxGetCwd(); - wxString prefix = ::wxPathOnly(path); - ::wxSetWorkingDirectory(prefix); - + wxString envpath; + bool hadpath = wxGetEnv(wxT("PATH"), &envpath); + wxSetEnv(wxT("PATH"), f.GetPath() + wxFILE_SEP_PATH + envpath); + wxString saveOldCWD = f.GetCwd(); + f.SetCwd(); + int index = 0; LADSPA_Descriptor_Function mainFn = NULL; wxDynamicLibrary lib; @@ -236,7 +237,8 @@ bool LadspaEffectsModule::RegisterPlugin(PluginManagerInterface & pm, const wxSt lib.Unload(); } - ::wxSetWorkingDirectory(saveOldCWD); + wxSetWorkingDirectory(saveOldCWD); + hadpath ? wxSetEnv(wxT("PATH"), envpath) : wxUnsetEnv(wxT("PATH")); return index > 0; } @@ -1507,6 +1509,13 @@ bool LadspaEffect::Load() return true; } + wxFileName f = mPath; + wxString envpath; + bool hadpath = wxGetEnv(wxT("PATH"), &envpath); + wxSetEnv(wxT("PATH"), f.GetPath() + wxFILE_SEP_PATH + envpath); + wxString saveOldCWD = f.GetCwd(); + f.SetCwd(); + LADSPA_Descriptor_Function mainFn = NULL; if (mLib.Load(mPath, wxDL_NOW)) @@ -1526,6 +1535,9 @@ bool LadspaEffect::Load() mLib.Unload(); } + wxSetWorkingDirectory(saveOldCWD); + hadpath ? wxSetEnv(wxT("PATH"), envpath) : wxUnsetEnv(wxT("PATH")); + return false; }