When opening a document from a different locale, MLT was resetting to default system locale

breaking the document
parent 1e1c236c
0.8.4
* Improve detection of locale issues (default to POSIX when there is a locale conflict on the system)
* Improve timeline operation for small clips (disable resizing, only allow move)
* Add background color parameter to "Rotate" and "Pan and Zoom" effects
* Allow to scroll using the mouse wheel in monitor editing scene
* Zoom to mouse when using CTRL + mouse wheel in monitor editing scene
......
......@@ -73,7 +73,7 @@ bool DocumentValidator::validate(const double currentVersion)
if (mlt.hasAttribute("LC_NUMERIC")) {
// Set locale for the document
QString newLocale = setlocale(LC_NUMERIC, mlt.attribute("LC_NUMERIC").toUtf8().constData());
const QString newLocale = setlocale(LC_NUMERIC, mlt.attribute("LC_NUMERIC").toUtf8().constData());
documentLocale = QLocale(mlt.attribute("LC_NUMERIC"));
// Make sure Qt locale and C++ locale have the same numeric separator, might not be the case
......@@ -96,11 +96,13 @@ bool DocumentValidator::validate(const double currentVersion)
documentLocale.setNumberOptions(QLocale::OmitGroupSeparator);
if (documentLocale.decimalPoint() != QLocale().decimalPoint()) {
// If loading an older MLT file without LC_NUMERIC, set locale to C which was previously the default
if (!mlt.hasAttribute("LC_NUMERIC")) setlocale(LC_NUMERIC, "C");
if (!mlt.hasAttribute("LC_NUMERIC")) {
setlocale(LC_NUMERIC, "C");
}
QLocale::setDefault(documentLocale);
// locale conversion might need to be redone
initEffects::parseEffectFiles();
initEffects::parseEffectFiles(setlocale(LC_NUMERIC, NULL));
}
bool ok;
......
......@@ -31,6 +31,8 @@
#include <QDir>
#include <QIcon>
#include "locale.h"
initEffectsThumbnailer::initEffectsThumbnailer() :
QThread()
{
......@@ -133,7 +135,7 @@ QDomDocument initEffects::getUsedCustomEffects(QMap <QString, QString> effectids
}
//static
void initEffects::parseEffectFiles()
void initEffects::parseEffectFiles(const QString &locale)
{
QStringList::Iterator more;
QStringList::Iterator it;
......@@ -146,6 +148,9 @@ void initEffects::parseEffectFiles()
return;
}
// Warning: Mlt::Factory::init() resets the locale to the default system value, make sure we keep correct locale
if (!locale.isEmpty()) setlocale(LC_NUMERIC, locale.toUtf8().constData());
// Retrieve the list of MLT's available effects.
Mlt::Properties *filters = repository->filters();
QStringList filtersList;
......
......@@ -54,7 +54,7 @@ public:
* It checks for all available effects and transitions, removes blacklisted
* ones, calls fillTransitionsList() and parseEffectFile() to fill the lists
* (with sorted, unique items) and then fills the global lists. */
static void parseEffectFiles();
static void parseEffectFiles(const QString &locale = QString());
static void refreshLumas();
static QDomDocument createDescriptionFromMlt(Mlt::Repository* repository, const QString& type, const QString& name);
static QDomDocument getUsedCustomEffects(QMap <QString, QString> effectids);
......
......@@ -125,7 +125,7 @@ KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup
systemLocale.setNumberOptions(QLocale::OmitGroupSeparator);
QLocale::setDefault(systemLocale);
// locale conversion might need to be redone
initEffects::parseEffectFiles();
initEffects::parseEffectFiles(setlocale(LC_NUMERIC, NULL));
}
*openBackup = false;
......
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