From 63dfb7610bc37dee69f4a303f3e3362529d95f24 Mon Sep 17 00:00:00 2001 From: falkTX Date: Fri, 29 Sep 2023 19:36:53 +0200 Subject: [PATCH] Reduce scope of ScopedSafeLocale usage on VST2, following others Signed-off-by: falkTX --- distrho/src/DistrhoPluginVST2.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/distrho/src/DistrhoPluginVST2.cpp b/distrho/src/DistrhoPluginVST2.cpp index 677f4a60..1941b2bc 100644 --- a/distrho/src/DistrhoPluginVST2.cpp +++ b/distrho/src/DistrhoPluginVST2.cpp @@ -757,7 +757,7 @@ public: } } - const std::size_t chunkSize(chunkStr.length()+1); + const std::size_t chunkSize = chunkStr.length()+1; fStateChunk = new char[chunkSize]; std::memcpy(fStateChunk, chunkStr.buffer(), chunkStr.length()); @@ -819,9 +819,6 @@ public: ++key; float fvalue; - // temporarily set locale to "C" while converting floats - const ScopedSafeLocale ssl; - while (bytesRead < chunkSize) { if (key[0] == '\0') @@ -839,7 +836,16 @@ public: if (fPlugin.getParameterSymbol(i) != key) continue; - fvalue = std::atof(value); + if (fPlugin.getParameterHints(i) & kParameterIsInteger) + { + fvalue = std::atoi(value); + } + else + { + const ScopedSafeLocale ssl; + fvalue = std::atof(value); + } + fPlugin.setParameterValue(i, fvalue); #if DISTRHO_PLUGIN_HAS_UI if (fVstUI != nullptr)