From f80662f8789b725485db137b127f0a00e8b02772 Mon Sep 17 00:00:00 2001 From: Jean Pierre Cimalando Date: Sun, 31 Oct 2021 22:20:10 +0100 Subject: [PATCH] jsfx: read/compile under scoped locale everywhere --- source/backend/plugin/CarlaPluginJSFX.cpp | 17 ++++++++++++----- source/backend/utils/CachedPlugins.cpp | 10 +++++++--- source/discovery/carla-discovery.cpp | 11 ++++++++--- 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/source/backend/plugin/CarlaPluginJSFX.cpp b/source/backend/plugin/CarlaPluginJSFX.cpp index 7ee0096a5..97387f22c 100644 --- a/source/backend/plugin/CarlaPluginJSFX.cpp +++ b/source/backend/plugin/CarlaPluginJSFX.cpp @@ -22,6 +22,7 @@ #include "CarlaEngine.hpp" #include "CarlaJsfxUtils.hpp" #include "CarlaBackendUtils.hpp" +#include "CarlaScopeUtils.hpp" #include "CarlaUtils.hpp" #include "water/files/File.h" @@ -287,8 +288,11 @@ public: | JsusFx::kCompileFlag_CompileSerializeSection ; - if (!fEffect->compile(*fPathLibrary, fFilename, compileFlags)) - carla_stderr("Failed to compile JSFX"); + { + const CarlaScopedLocale csl; + if (!fEffect->compile(*fPathLibrary, fFilename, compileFlags)) + carla_stderr("Failed to compile JSFX"); + } // initialize the block size and sample rate // loading the chunk can invoke @slider which makes computations based on these @@ -854,10 +858,13 @@ public: // --------------------------------------------------------------- // get info - if (!fEffect->readHeader(*fPathLibrary, filename)) { - pData->engine->setLastError("Cannot read the JSFX header"); - return false; + const CarlaScopedLocale csl; + if (!fEffect->readHeader(*fPathLibrary, filename)) + { + pData->engine->setLastError("Cannot read the JSFX header"); + return false; + } } // jsusfx lacks validity checks currently, diff --git a/source/backend/utils/CachedPlugins.cpp b/source/backend/utils/CachedPlugins.cpp index 846fedb65..ead475503 100644 --- a/source/backend/utils/CachedPlugins.cpp +++ b/source/backend/utils/CachedPlugins.cpp @@ -20,6 +20,7 @@ #include "CarlaNative.h" #include "CarlaString.hpp" #include "CarlaBackendUtils.hpp" +#include "CarlaScopeUtils.hpp" #include "CarlaLv2Utils.hpp" #include "CarlaJsfxUtils.hpp" @@ -673,10 +674,13 @@ static const CarlaCachedPluginInfo* get_cached_plugin_jsfx(const water::File& fi name = file.getFileNameWithoutExtension().toRawUTF8(); filename = file.getFullPathName().toRawUTF8(); - if (!effect.readHeader(pathLibrary, filename.buffer())) { - info.valid = false; - return &info; + const CarlaScopedLocale csl; + if (!effect.readHeader(pathLibrary, filename.buffer())) + { + info.valid = false; + return &info; + } } if (effect.desc[0] == '\0') { diff --git a/source/discovery/carla-discovery.cpp b/source/discovery/carla-discovery.cpp index e5e439925..3213a6475 100644 --- a/source/discovery/carla-discovery.cpp +++ b/source/discovery/carla-discovery.cpp @@ -18,6 +18,7 @@ #include "CarlaBackendUtils.hpp" #include "CarlaLibUtils.hpp" #include "CarlaMathUtils.hpp" +#include "CarlaScopeUtils.hpp" #include "CarlaMIDI.h" #include "LinkedList.hpp" @@ -1689,10 +1690,13 @@ static void do_jsfx_check(const char* const filename, bool doInit) JsusFx::kCompileFlag_CompileSerializeSection | JsusFx::kCompileFlag_CompileGraphicsSection; - if (!effect.compile(pathLibrary, filename, compileFlags)) { - DISCOVERY_OUT("error", "Cannot compile the JSFX plugin"); - return; + const CarlaScopedLocale csl; + if (!effect.compile(pathLibrary, filename, compileFlags)) + { + DISCOVERY_OUT("error", "Cannot compile the JSFX plugin"); + return; + } } #if 0 // TODO(jsfx) when supporting custom graphics @@ -1703,6 +1707,7 @@ static void do_jsfx_check(const char* const filename, bool doInit) } else { + const CarlaScopedLocale csl; if (!effect.readHeader(pathLibrary, filename)) { DISCOVERY_OUT("error", "Cannot read the JSFX header");