Merge branch 'master' of https://github.com/olive-editor/olive
This commit is contained in:
@@ -51,7 +51,7 @@ OCIO::ConstConfigRcPtr ColorManager::GetConfig() const
|
||||
|
||||
OCIO::ConstConfigRcPtr ColorManager::CreateConfigFromFile(const QString &filename)
|
||||
{
|
||||
SetCLocale();
|
||||
OCIO_SET_C_LOCALE_FOR_SCOPE;
|
||||
|
||||
return OCIO::Config::CreateFromFile(filename.toUtf8());
|
||||
}
|
||||
@@ -68,10 +68,11 @@ OCIO::ConstConfigRcPtr ColorManager::GetDefaultConfig()
|
||||
|
||||
void ColorManager::SetUpDefaultConfig()
|
||||
{
|
||||
OCIO_SET_C_LOCALE_FOR_SCOPE;
|
||||
|
||||
if (!qgetenv("OCIO").isEmpty()) {
|
||||
// Attempt to set config from "OCIO" environment variable
|
||||
try {
|
||||
SetCLocale();
|
||||
default_config_ = OCIO::Config::CreateFromEnv();
|
||||
|
||||
return;
|
||||
@@ -381,4 +382,15 @@ void ColorManager::AssociateAlphaInternal(ColorManager::AlphaAction action, T *d
|
||||
}
|
||||
}
|
||||
|
||||
ColorManager::SetLocale::SetLocale(const char* new_locale)
|
||||
{
|
||||
old_locale_ = setlocale(LC_NUMERIC, nullptr);
|
||||
setlocale(LC_NUMERIC, new_locale);
|
||||
}
|
||||
|
||||
ColorManager::SetLocale::~SetLocale()
|
||||
{
|
||||
setlocale(LC_NUMERIC, old_locale_.toUtf8());
|
||||
}
|
||||
|
||||
OLIVE_NAMESPACE_EXIT
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
#include "codec/frame.h"
|
||||
#include "colorprocessor.h"
|
||||
|
||||
#define OCIO_SET_C_LOCALE_FOR_SCOPE ColorManager::SetLocale d("C")
|
||||
|
||||
OLIVE_NAMESPACE_ENTER
|
||||
|
||||
class ColorManager : public QObject
|
||||
@@ -92,50 +94,15 @@ public:
|
||||
|
||||
static void SetOCIOMethodForMode(RenderMode::Mode mode, OCIOMethod method);
|
||||
|
||||
class SetCLocale
|
||||
class SetLocale
|
||||
{
|
||||
public:
|
||||
SetCLocale()
|
||||
{
|
||||
#ifdef Q_OS_WINDOWS
|
||||
// set locale will only change locale on the current thread
|
||||
previousThreadConfig = _configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
|
||||
SetLocale(const char* new_locale);
|
||||
|
||||
// get and store current locale
|
||||
ssaLocale.convert(setlocale(LC_ALL, NULL));
|
||||
|
||||
// set to "C" locale
|
||||
setlocale(LC_ALL, "C");
|
||||
#else
|
||||
// set to C locale, saving the old one (returned from useLocale)
|
||||
currentLocale = newlocale(LC_ALL_MASK,"C",NULL);
|
||||
oldLocale = uselocale(currentLocale);
|
||||
#endif
|
||||
}
|
||||
|
||||
~SetCLocale()
|
||||
{
|
||||
#ifdef Q_OS_WINDOWS
|
||||
// thread specific
|
||||
setlocale(LC_ALL, ssaLocale.c_str());
|
||||
|
||||
// set back to global settings]
|
||||
_configthreadlocale(previousThreadConfig);
|
||||
#else
|
||||
// restore the previous locale and freeing the created locale
|
||||
uselocale(oldLocale);
|
||||
freelocale(currentLocale);
|
||||
#endif
|
||||
}
|
||||
~SetLocale();
|
||||
|
||||
private:
|
||||
#ifdef Q_OS_WINDOWS
|
||||
SoStringA ssaLocale;
|
||||
int previousThreadConfig;
|
||||
#else
|
||||
locale_t oldLocale;
|
||||
locale_t currentLocale;
|
||||
#endif
|
||||
QString old_locale_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -44,10 +44,12 @@ ColorProcessor::ColorProcessor(ColorManager *config, const QString &input, const
|
||||
display_transform->setLooksOverrideEnabled(true);
|
||||
}
|
||||
|
||||
OCIO_SET_C_LOCALE_FOR_SCOPE;
|
||||
processor_ = config->GetConfig()->getProcessor(display_transform);
|
||||
|
||||
} else {
|
||||
|
||||
OCIO_SET_C_LOCALE_FOR_SCOPE;
|
||||
processor_ = config->GetConfig()->getProcessor(input.toUtf8(),
|
||||
output.toUtf8());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user