Commit cf951dbc authored by Simon Eugster's avatar Simon Eugster

Remove deprecated locale related code

Locale is now set after initialising MLT factory.

Related: #713
parent 26b583b0
......@@ -80,11 +80,6 @@ RenderJob::~RenderJob()
m_logfile.close();
}
void RenderJob::setLocale(const QString &locale)
{
qputenv("LC_NUMERIC", locale.toUtf8().constData());
}
void RenderJob::slotAbort(const QString &url)
{
if (m_dest == url) {
......
......@@ -35,7 +35,6 @@ class RenderJob : public QObject
public:
RenderJob(const QString &render, const QString &scenelist, const QString &target, int pid = -1, int in = -1, int out = -1, QObject *parent = nullptr);
~RenderJob();
void setLocale(const QString &locale);
public slots:
void start();
......
......@@ -38,13 +38,6 @@ template <typename AssetType> AbstractAssetsRepository<AssetType>::AbstractAsset
template <typename AssetType> void AbstractAssetsRepository<AssetType>::init()
{
// Warning: Mlt::Factory::init() resets the locale to the default system value, make sure we keep correct locale
#ifndef Q_OS_MAC
setlocale(LC_NUMERIC, nullptr);
#else
setlocale(LC_NUMERIC_MASK, nullptr);
#endif
// Parse blacklist
parseAssetList(assetBlackListPath(), m_blacklist);
......
......@@ -285,30 +285,8 @@ MixerManager *Core::mixer()
void Core::initLocale()
{
qDebug() << "Using modified system locale without group separator for numbers";
QLocale systemLocale = QLocale();
#ifndef Q_OS_MAC
setlocale(LC_NUMERIC, nullptr);
#else
setlocale(LC_NUMERIC_MASK, nullptr);
#endif
// localeconv()->decimal_point does not give reliable results on Windows
#ifndef Q_OS_WIN
char *separator = localeconv()->decimal_point;
if (QString::fromUtf8(separator) != QChar(systemLocale.decimalPoint())) {
// qCDebug(KDENLIVE_LOG)<<"------\n!!! system locale is not similar to Qt's locale... be prepared for bugs!!!\n------";
// HACK: There is a locale conflict, so set locale to C
// Make sure to override exported values or it won't work
qputenv("LANG", "C");
#ifndef Q_OS_MAC
setlocale(LC_NUMERIC, "C");
#else
setlocale(LC_NUMERIC_MASK, "C");
#endif
systemLocale = QLocale::c();
}
#endif
systemLocale.setNumberOptions(QLocale::OmitGroupSeparator);
QLocale::setDefault(systemLocale);
}
......
......@@ -185,14 +185,6 @@ bool DocumentValidator::validate(const double currentVersion)
"\"%2\". Change your computer settings or you might not be able to correctly open the project.",
documentLocale.decimalPoint(), QLocale().decimalPoint()));
}
// locale conversion might need to be redone
// TODO reload repositories
/*#ifndef Q_OS_MAC
initEffects::parseEffectFiles(pCore->getMltRepository(), QString::fromLatin1(setlocale(LC_NUMERIC, nullptr)));
#else
initEffects::parseEffectFiles(pCore->getMltRepository(), QString::fromLatin1(setlocale(LC_NUMERIC_MASK, nullptr)));
#endif
*/
}
double version = -1;
if (kdenliveDoc.isNull() || !kdenliveDoc.hasAttribute(QStringLiteral("version"))) {
......
......@@ -128,19 +128,6 @@ KdenliveDoc::KdenliveDoc(const QUrl &url, QString projectFolder, QUndoGroup *und
j.next();
m_documentMetadata[j.key()] = j.value();
}
/*if (QLocale().decimalPoint() != QLocale::system().decimalPoint()) {
qDebug()<<"* * ** AARCH DOCUMENT PROBLEM;";
exit(1);
setlocale(LC_NUMERIC, "");
QLocale systemLocale = QLocale::system();
systemLocale.setNumberOptions(QLocale::OmitGroupSeparator);
QLocale::setDefault(systemLocale);
// locale conversion might need to be redone
///TODO: how to reset repositories...
//EffectsRepository::get()->init();
//TransitionsRepository::get()->init();
//initEffects::parseEffectFiles(pCore->getMltRepository(), QString::fromLatin1(setlocale(LC_NUMERIC, nullptr)));
}*/
*openBackup = false;
if (url.isValid()) {
QFile file(url.toLocalFile());
......@@ -1274,7 +1261,6 @@ QMap<QString, QString> KdenliveDoc::documentProperties()
m_projectFolder + QLatin1Char('/') + m_documentProperties.value(QStringLiteral("documentid")));
}
m_documentProperties.insert(QStringLiteral("profile"), pCore->getCurrentProfile()->path());
;
if (!m_documentProperties.contains(QStringLiteral("decimalPoint"))) {
m_documentProperties.insert(QStringLiteral("decimalPoint"), QLocale().decimalPoint());
}
......
......@@ -91,6 +91,7 @@ MltConnection::MltConnection(const QString &mltPath)
m_repository = std::unique_ptr<Mlt::Repository>(Mlt::Factory::init());
std::setlocale(LC_ALL, "C");
::qputenv("LC_ALL", "C");
qDebug() << "LC_ALL set to C after initialising MLT";
locateMeltAndProfilesPath(mltPath);
......
......@@ -282,27 +282,6 @@ bool ProjectManager::closeCurrentDocument(bool saveChanges, bool quit)
m_project = nullptr;
}
}
/* // Make sure to reset locale to system's default
QString requestedLocale = QLocale::system().name();
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
if (env.contains(QStringLiteral("LC_NUMERIC"))) {
requestedLocale = env.value(QStringLiteral("LC_NUMERIC"));
}
qDebug()<<"//////////// RESETTING LOCALE TO: "<<requestedLocale;
#ifdef Q_OS_MAC
setlocale(LC_NUMERIC_MASK, requestedLocale.toUtf8().constData());
#elif defined(Q_OS_WIN)
std::locale::global(std::locale(requestedLocale.toUtf8().constData()));
#else
QLocale newLocale(requestedLocale);
char *separator = localeconv()->decimal_point;
if (QString::fromUtf8(separator) != QString(newLocale.decimalPoint())) {
pCore->displayBinMessage(i18n("There is a locale conflict on your system, project might get corrupt"), KMessageWidget::Warning);
}
setlocale(LC_NUMERIC, requestedLocale.toUtf8().constData());
#endif
QLocale::setDefault(newLocale);*/
return true;
}
......
......@@ -41,6 +41,7 @@ MltPreview::MltPreview()
Mlt::Factory::init();
std::setlocale(LC_ALL, "C");
::qputenv("LC_ALL", "C");
qDebug() << "LC_ALL set to C after initialising MLT";
}
MltPreview::~MltPreview()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment