From 605e894b11cf327e8838a8d1a587f64200ab2a66 Mon Sep 17 00:00:00 2001 From: falkTX Date: Sun, 7 Feb 2021 23:08:03 +0000 Subject: [PATCH] Fix assertion on empty project path; Change cwd of plugin bridges Signed-off-by: falkTX --- source/backend/engine/CarlaEngine.cpp | 3 ++- source/backend/plugin/CarlaPluginBridge.cpp | 14 +++++++++++++- source/modules/water/files/File.cpp | 10 ++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/source/backend/engine/CarlaEngine.cpp b/source/backend/engine/CarlaEngine.cpp index 9e0755ba0..6201ad5c9 100644 --- a/source/backend/engine/CarlaEngine.cpp +++ b/source/backend/engine/CarlaEngine.cpp @@ -1406,7 +1406,8 @@ bool CarlaEngine::saveProject(const char* const filename, const bool setAsCurren #ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH const char* CarlaEngine::getCurrentProjectFolder() const noexcept { - return pData->currentProjectFolder; + return pData->currentProjectFolder.isNotEmpty() ? pData->currentProjectFolder.buffer() + : nullptr; } const char* CarlaEngine::getCurrentProjectFilename() const noexcept diff --git a/source/backend/plugin/CarlaPluginBridge.cpp b/source/backend/plugin/CarlaPluginBridge.cpp index 82757d479..97b3e8d13 100644 --- a/source/backend/plugin/CarlaPluginBridge.cpp +++ b/source/backend/plugin/CarlaPluginBridge.cpp @@ -320,7 +320,19 @@ protected: carla_stdout("Starting plugin bridge, command is:\n%s \"%s\" \"%s\" \"%s\" " P_INT64, fBridgeBinary.toRawUTF8(), getPluginTypeAsString(kPlugin->getType()), filename.toRawUTF8(), fLabel.toRawUTF8(), kPlugin->getUniqueId()); - started = fProcess->start(arguments); + const File projFolder(kEngine->getCurrentProjectFolder()); + + if (projFolder.isNotNull()) + { + const File oldFolder(File::getCurrentWorkingDirectory()); + projFolder.setAsCurrentWorkingDirectory(); + started = fProcess->start(arguments); + oldFolder.setAsCurrentWorkingDirectory(); + } + else + { + started = fProcess->start(arguments); + } } if (! started) diff --git a/source/modules/water/files/File.cpp b/source/modules/water/files/File.cpp index a44ea3579..22a9dc1d7 100644 --- a/source/modules/water/files/File.cpp +++ b/source/modules/water/files/File.cpp @@ -1109,6 +1109,11 @@ File File::getCurrentWorkingDirectory() return File (String (dest)); } +bool File::setAsCurrentWorkingDirectory() const +{ + return SetCurrentDirectory (getFullPathName().toWideCharPointer()) != FALSE; +} + bool File::isSymbolicLink() const { return (GetFileAttributes (fullPath.toUTF8()) & FILE_ATTRIBUTE_REPARSE_POINT) != 0; @@ -1342,6 +1347,11 @@ File File::getCurrentWorkingDirectory() return File (CharPointer_UTF8 (cwd)); } +bool File::setAsCurrentWorkingDirectory() const +{ + return chdir (getFullPathName().toUTF8()) == 0; +} + File water_getExecutableFile(); File water_getExecutableFile() {