From: Till Theato Date: Sun, 28 Aug 2011 18:27:23 +0000 (+0000) Subject: Fix issues when switching between projects with different locales. X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;ds=sidebyside;h=b3b1b1c1d6e229744ebd10093305c69fbf7ae9b0;p=kdenlive Fix issues when switching between projects with different locales. svn path=/trunk/kdenlive/; revision=5843 --- diff --git a/src/documentvalidator.cpp b/src/documentvalidator.cpp index 3cc588b8..185d597e 100644 --- a/src/documentvalidator.cpp +++ b/src/documentvalidator.cpp @@ -29,9 +29,12 @@ #include #include +#include #include +#include "locale.h" + DocumentValidator::DocumentValidator(QDomDocument doc): m_doc(doc), @@ -51,13 +54,17 @@ bool DocumentValidator::validate(const double currentVersion) return false; // Previous MLT / Kdenlive versions used C locale by default - QLocale documentLocale("C"); + QLocale documentLocale = QLocale::c(); if (mlt.hasAttribute("LC_NUMERIC")) { // Set locale for the document + // WARNING: what should be done in case the locale does not exist on the system? + setlocale(LC_NUMERIC, mlt.attribute("LC_NUMERIC").toUtf8().constData()); documentLocale = QLocale(mlt.attribute("LC_NUMERIC")); } + documentLocale.setNumberOptions(QLocale::OmitGroupSeparator); + if (documentLocale != QLocale()) { QLocale::setDefault(documentLocale); // locale conversion might need to be redone diff --git a/src/kdenlivedoc.cpp b/src/kdenlivedoc.cpp index ddc79e29..11a7a9cf 100644 --- a/src/kdenlivedoc.cpp +++ b/src/kdenlivedoc.cpp @@ -53,6 +53,9 @@ #include +#include "locale.h" + + const double DOCUMENTVERSION = 0.88; KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup *undoGroup, QString profileName, QMap properties, const QPoint tracks, Render *render, KTextEdit *notes, bool *openBackup, MainWindow *parent, KProgressDialog *progressDialog) : @@ -96,7 +99,10 @@ KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup m_documentProperties[i.key()] = i.value(); } - if (QLocale() != QLocale::system()) { + QLocale locale = QLocale::system(); + locale.setNumberOptions(QLocale::OmitGroupSeparator); + if (QLocale() != locale) { + setlocale(LC_NUMERIC, ""); QLocale::setDefault(QLocale::system()); // locale conversion might need to be redone initEffects::parseEffectFiles(); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 8d9b0edc..c3efd3da 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -154,7 +154,6 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, const QString & new MainWindowAdaptor(this); QDBusConnection dbus = QDBusConnection::sessionBus(); dbus.registerObject("/MainWindow", this); - //setlocale(LC_NUMERIC, "POSIX"); if (!KdenliveSettings::colortheme().isEmpty()) slotChangePalette(NULL, KdenliveSettings::colortheme()); setFont(KGlobalSettings::toolBarFont()); parseProfiles(MltPath);