diff --git a/source/discovery/carla-discovery.cpp b/source/discovery/carla-discovery.cpp index 2195f7e23..7970b8a7f 100644 --- a/source/discovery/carla-discovery.cpp +++ b/source/discovery/carla-discovery.cpp @@ -1596,6 +1596,7 @@ static void do_fluidsynth_check(const char* const filename, const PluginType typ // unused (void)filename; + (void)type; (void)doInit; #endif } @@ -1644,6 +1645,8 @@ int main(int argc, char* argv[]) // --------------------------------------------------------------------- // Initialize OS features + const CarlaScopedLocale csl; + #ifdef CARLA_OS_WIN OleInitialize(nullptr); CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); diff --git a/source/utils/CarlaScopeUtils.hpp b/source/utils/CarlaScopeUtils.hpp index 0321d9028..30e59da37 100644 --- a/source/utils/CarlaScopeUtils.hpp +++ b/source/utils/CarlaScopeUtils.hpp @@ -2,7 +2,7 @@ * Carla Scope-related classes and tools (pointer and setter taken from JUCE v4) * Copyright (C) 2013 Raw Material Software Ltd. * Copyright (c) 2016 ROLI Ltd. - * Copyright (C) 2013-2019 Filipe Coelho + * Copyright (C) 2013-2020 Filipe Coelho * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -25,6 +25,10 @@ #include #include +#if defined(CARLA_PROPER_CPP11_SUPPORT) && ! defined(CARLA_OS_WIN) +# define CARLA_USE_NEWLOCALE +#endif + // ----------------------------------------------------------------------- // CarlaScopedEnvVar class @@ -89,24 +93,55 @@ private: // CarlaScopedLocale class class CarlaScopedLocale { +#ifdef CARLA_USE_NEWLOCALE + static constexpr locale_t kNullLocale = (locale_t)0; +#endif + public: CarlaScopedLocale() noexcept - : locale(carla_strdup_safe(::setlocale(LC_NUMERIC, nullptr))) +#ifdef CARLA_USE_NEWLOCALE + : newloc(::newlocale(LC_NUMERIC_MASK, "C", kNullLocale)), + oldloc(newloc != kNullLocale ? ::uselocale(newloc) : kNullLocale) {} +#else +# ifdef CARLA_OS_WIN + : oldthreadloc(_configthreadlocale(_ENABLE_PER_THREAD_LOCALE)), +# else + : oldthreadloc(-1), +# endif + oldloc(carla_strdup_safe(::setlocale(LC_NUMERIC, nullptr))) { ::setlocale(LC_NUMERIC, "C"); } +#endif ~CarlaScopedLocale() noexcept { - if (locale != nullptr) +#ifdef CARLA_USE_NEWLOCALE + if (oldloc != kNullLocale) + ::uselocale(oldloc); + if (newloc != kNullLocale) + ::freelocale(newloc); +#else // CARLA_USE_NEWLOCALE + if (oldloc != nullptr) { - ::setlocale(LC_NUMERIC, locale); - delete[] locale; + ::setlocale(LC_NUMERIC, oldloc); + delete[] oldloc; } + +# ifdef CARLA_OS_WIN + if (oldthreadloc != -1) + _configthreadlocale(oldthreadloc); +# endif +#endif // CARLA_USE_NEWLOCALE } private: - const char* const locale; +#ifdef CARLA_USE_NEWLOCALE + locale_t newloc, oldloc; +#else + const int oldthreadloc; + const char* const oldloc; +#endif CARLA_DECLARE_NON_COPY_CLASS(CarlaScopedLocale) CARLA_PREVENT_HEAP_ALLOCATION