[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kdenlive] src: Merge branch '16.12'
From:       Jean-Baptiste Mardelle <null () kde ! org>
Date:       2017-01-07 23:32:34
Message-ID: E1cQ0TS-0000Hp-QQ () code ! kde ! org
[Download RAW message or body]

Git commit 300b89d09afb1f5036dbd289be8906197d534a7e by Jean-Baptiste Mardelle.
Committed on 07/01/2017 at 23:32.
Pushed by mardelle into branch 'master'.

Merge branch '16.12'

M  +4    -0    src/core.cpp
M  +4    -3    src/doc/documentchecker.cpp
M  +78   -16   src/doc/documentvalidator.cpp
M  +3    -0    src/doc/kdenlivedoc.cpp
M  +1    -1    src/mainwindow.cpp
M  +7    -4    src/mltcontroller/bincontroller.cpp
M  +1    -1    src/project/dialogs/archivewidget.cpp
M  +1    -1    src/project/dialogs/projectsettings.cpp
M  +9    -2    src/project/projectmanager.cpp

https://commits.kde.org/kdenlive/300b89d09afb1f5036dbd289be8906197d534a7e

diff --cc src/core.cpp
index 5d22b7283,a869bc201..efb91198a
--- a/src/core.cpp
+++ b/src/core.cpp
@@@ -128,13 -130,16 +128,16 @@@ void Core::initLocale(
  {
      QLocale systemLocale = QLocale();
  #ifndef Q_OS_MAC
 -    setlocale(LC_NUMERIC, NULL);
 +    setlocale(LC_NUMERIC, Q_NULLPTR);
  #else
 -    setlocale(LC_NUMERIC_MASK, NULL);
 +    setlocale(LC_NUMERIC_MASK, Q_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())) {
 -        //qDebug()<<"------\n!!! system locale is not similar to Qt's locale... be \
prepared for bugs!!!\n------";  +        //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");
diff --cc src/doc/documentvalidator.cpp
index d31779837,6bf3b5d3e..91cf3b795
--- a/src/doc/documentvalidator.cpp
+++ b/src/doc/documentvalidator.cpp
@@@ -44,12 -45,10 +44,10 @@@
  
  #include <QStandardPaths>
  
- #define AMPTODBFS(x) pow(10,20.0/(x))
- 
  DocumentValidator::DocumentValidator(const QDomDocument &doc, const QUrl \
                &documentUrl):
 -        m_doc(doc),
 -        m_url(documentUrl),
 -        m_modified(false)
 +    m_doc(doc),
 +    m_url(documentUrl),
 +    m_modified(false)
  {}
  
  bool DocumentValidator::validate(const double currentVersion)
@@@ -75,34 -73,94 +73,96 @@@
      QLocale documentLocale = QLocale::c();
  
      if (mlt.hasAttribute(QStringLiteral("LC_NUMERIC"))) {
-         // Set locale for the document
+         // Check document numeric separator (added in Kdenlive 16.12.1
+         QDomElement main_playlist = \
mlt.firstChildElement(QStringLiteral("playlist")); +         QDomNodeList props = \
main_playlist.elementsByTagName(QStringLiteral("property")); +         QChar \
numericalSeparator; +         for (int i = 0; i < props.count(); ++i) {
+             QDomNode n = props.at(i);
+             if (n.toElement().attribute(QStringLiteral("name")) == \
QLatin1String("kdenlive:docproperties.decimalPoint")) { +                 QString sep \
= n.firstChild().nodeValue(); +                 if (!sep.isEmpty()) {
+                     numericalSeparator = sep.at(0);
+                 }
+                 break;
+             }
+         }
+         bool error = false;
+         if (!numericalSeparator.isNull() && numericalSeparator != \
                QLocale().decimalPoint()) {
 -            qDebug()<<" * ** LOCALE CHANGE REQUIRED: "<<numericalSeparator <<"!="<< \
QLocale().decimalPoint()<<" / "<<QLocale::system().decimalPoint(); ++            \
qCDebug(KDENLIVE_LOG)<<" * ** LOCALE CHANGE REQUIRED: "<<numericalSeparator <<"!="<< \
QLocale().decimalPoint()<<" / "<<QLocale::system().decimalPoint(); +             // \
Change locale to match document +             QString requestedLocale = \
mlt.attribute(QStringLiteral("LC_NUMERIC")); +             documentLocale = \
QLocale(requestedLocale); + #ifdef Q_OS_WIN
+             // Most locales don't work on windows, so use C whenever possible
+             if (numericalSeparator == QLatin1Char('.')) {
+ #else
+             if (numericalSeparator != documentLocale.decimalPoint() && \
numericalSeparator == QLatin1Char('.')) { + #endif
+                 requestedLocale = QStringLiteral("C");
+                 documentLocale = QLocale::c();
+             }
+ #ifdef Q_OS_MAC
+             setlocale(LC_NUMERIC_MASK, requestedLocale.toUtf8().constData());
+ #elifdef Q_OS_WIN
+             std::locale::global(std::locale(requestedLocale.toUtf8().constData()));
+ #else
+             setlocale(LC_NUMERIC, requestedLocale.toUtf8().constData());
+ #endif
+             if (numericalSeparator != documentLocale.decimalPoint()) {
+                 // Parse installed locales to find one matching
+                 const QList<QLocale> list = \
QLocale::matchingLocales(QLocale::AnyLanguage, QLocale().script(), \
QLocale::AnyCountry); +                 QLocale matching;
+                 foreach(const QLocale &loc, list) {
+                     if (loc.decimalPoint() == numericalSeparator) {
+                         matching = loc;
 -                        qDebug()<<"Warning, document locale: \
"<<mlt.attribute(QStringLiteral("LC_NUMERIC"))<<" is not available, using: \
"<<loc.name(); ++                        qCDebug(KDENLIVE_LOG)<<"Warning, document \
locale: "<<mlt.attribute(QStringLiteral("LC_NUMERIC"))<<" is not available, using: \
"<<loc.name();  #ifndef Q_OS_MAC
-         const QString newLocale = setlocale(LC_NUMERIC, \
mlt.attribute(QStringLiteral("LC_NUMERIC")).toUtf8().constData()); +                  \
setlocale(LC_NUMERIC, loc.name().toUtf8().constData());  #else
-         const QString newLocale = setlocale(LC_NUMERIC_MASK, \
mlt.attribute("LC_NUMERIC").toUtf8().constData()); +                         \
setlocale(LC_NUMERIC_MASK, loc.name().toUtf8().constData());  #endif
-         documentLocale = QLocale(mlt.attribute(QStringLiteral("LC_NUMERIC")));
- 
-         // Make sure Qt locale and C++ locale have the same numeric separator, \
                might not be the case
-         // With some locales since C++ and Qt use a different database for locales
-         char *separator = localeconv()->decimal_point;
-         if (newLocale.isEmpty()) {
+                         documentLocale = matching;
+                         break;
+                     }
+                 }
+                 error = numericalSeparator != documentLocale.decimalPoint();
+             }
 -
+         } else if (numericalSeparator.isNull()) {
+             // Change locale to match document
+ #ifndef Q_OS_MAC
+             const QString newloc = setlocale(LC_NUMERIC, \
mlt.attribute(QStringLiteral("LC_NUMERIC")).toUtf8().constData()); + #else
+             const QString newloc = setlocale(LC_NUMERIC_MASK, \
mlt.attribute("LC_NUMERIC").toUtf8().constData()); + #endif
+             documentLocale = QLocale(mlt.attribute(QStringLiteral("LC_NUMERIC")));
+             error = newloc.isEmpty();
+         } else {
+             // Document separator matching system separator
+             documentLocale = QLocale();
+         }
+         if (error) {
              // Requested locale not available, ask for install
              KMessageBox::sorry(QApplication::activeWindow(), i18n("The document was \
created in \"%1\" locale, which is not installed on your system. Please install that \
language pack. Until then, Kdenlive might not be able to correctly open the \
document.", mlt.attribute("LC_NUMERIC")));  }
  
+         // Make sure Qt locale and C++ locale have the same numeric separator, \
might not be the case +         // With some locales since C++ and Qt use a different \
database for locales +         // localeconv()->decimal_point does not give reliable \
results on Windows + #ifndef Q_OS_WIN
+         char *separator = localeconv()->decimal_point;
 -        if (QLatin1Char(separator[0]) != documentLocale.decimalPoint()) {
 +        if (QString::fromUtf8(separator) != QString(documentLocale.decimalPoint())) \
                {
-             KMessageBox::sorry(QApplication::activeWindow(), i18n("There is a \
locale conflict on your system. The document uses locale %1 which uses a \"%2\" as \
numeric separator (in system libraries) but Qt expects \"%3\". You might not be able \
to correctly open the project.", mlt.attribute("LC_NUMERIC"), separator, \
                documentLocale.decimalPoint()));
-             //qCDebug(KDENLIVE_LOG)<<"------\n!!! system locale is not similar to \
Qt's locale... be prepared for bugs!!!\n------"; + 	    \
KMessageBox::sorry(QApplication::activeWindow(), i18n("There is a locale conflict on \
your system. The document uses locale %1 which uses a \"%2\" as numeric separator (in \
system libraries) but Qt expects \"%3\". You might not be able to correctly open the \
project.", mlt.attribute("LC_NUMERIC"), documentLocale.decimalPoint(), separator)); + \
//qDebug()<<"------\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 at least have \
                correct decimal point
 -            if (strncmp(separator, ".", 1) == 0) documentLocale = QLocale::c();
 -            else if (strncmp(separator, ",", 1) == 0) documentLocale = \
QLocale(QStringLiteral("fr_FR.UTF-8"));  +            if (strncmp(separator, ".", 1) \
== 0) {  +                documentLocale = QLocale::c();
 +            } else if (strncmp(separator, ",", 1) == 0) {
 +                documentLocale = QLocale(QStringLiteral("fr_FR.UTF-8"));
 +            }
          }
+ #endif
      }
- 
      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 @@@ -112,14 -170,16 +172,16 @@@
  #else
              setlocale(LC_NUMERIC_MASK, "C");
  #endif
-         }
- 
+ 	}
          QLocale::setDefault(documentLocale);
+         if (documentLocale.decimalPoint() != QLocale().decimalPoint()) {
+             KMessageBox::sorry(QApplication::activeWindow(), i18n("There is a \
locale conflict. The document uses a \"%1\" as numeric separator, but your computer \
is configured to use \"%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
  #ifndef Q_OS_MAC
 -        initEffects::parseEffectFiles(pCore->binController()->mltRepository(), \
setlocale(LC_NUMERIC, NULL));  +        \
initEffects::parseEffectFiles(pCore->binController()->mltRepository(), \
setlocale(LC_NUMERIC, Q_NULLPTR));  #else
 -        initEffects::parseEffectFiles(pCore->binController()->mltRepository(), \
setlocale(LC_NUMERIC_MASK, NULL));  +        \
initEffects::parseEffectFiles(pCore->binController()->mltRepository(), \
setlocale(LC_NUMERIC_MASK, Q_NULLPTR));  #endif
      }
      double version = -1;
diff --cc src/mltcontroller/bincontroller.cpp
index fcec83121,a810d975a..bdf99c105
--- a/src/mltcontroller/bincontroller.cpp
+++ b/src/mltcontroller/bincontroller.cpp
@@@ -604,20 -595,18 +607,20 @@@ QMap<QString, QString> BinController::g
      int size = m_binPlaylist->count();
      for (int i = 0; i < size; i++) {
          QScopedPointer<Mlt::Producer> prod(m_binPlaylist->get_clip(i));
 -	if (!prod->is_valid() || prod->is_blank()) continue;
 +        if (!prod->is_valid() || prod->is_blank()) {
 +            continue;
 +        }
          QString proxy = prod->parent().get("kdenlive:proxy");
-         if (proxy.length() > 2) {
-             if (!proxy.startsWith(QLatin1Char('/'))) {
+ 	if (proxy.length() > 2) {
+             if (QFileInfo(proxy).isRelative()) {
                  proxy.prepend(m_documentRoot);
              }
              QString sourceUrl(prod->parent().get("kdenlive:originalurl"));
-             if (!sourceUrl.startsWith(QLatin1Char('/'))) {
+             if (QFileInfo(sourceUrl).isRelative()) {
                  sourceUrl.prepend(m_documentRoot);
              }
 -	    proxies.insert(proxy, sourceUrl);
 -	}
 +            proxies.insert(proxy, sourceUrl);
 +        }
      }
      return proxies;
  }
diff --cc src/project/projectmanager.cpp
index d4b4875c1,9659d67a8..48f3914a9
--- a/src/project/projectmanager.cpp
+++ b/src/project/projectmanager.cpp
@@@ -141,11 -146,14 +142,14 @@@ void ProjectManager::newFile(bool showP
          }
          if (KdenliveSettings::customprojectfolder()) {
              projectFolder = KdenliveSettings::defaultprojectfolder();
-             documentProperties.insert(QStringLiteral("storagefolder"), \
projectFolder + QStringLiteral("/") + documentId); +             if \
(!projectFolder.endsWith(QLatin1Char('/'))) { +                 \
projectFolder.append(QStringLiteral("/")); +             }
+             documentProperties.insert(QStringLiteral("storagefolder"), \
projectFolder + documentId);  }
      } else {
 -        QPointer<ProjectSettings> w = new ProjectSettings(NULL, QMap <QString, \
QString> (), QStringList(), projectTracks.x(), projectTracks.y(), \
                KdenliveSettings::defaultprojectfolder(), false, true, \
                pCore->window());
 -        connect(w, SIGNAL(refreshProfiles()), pCore->window(), \
SLOT(slotRefreshProfiles()));  +        QPointer<ProjectSettings> w = new \
ProjectSettings(Q_NULLPTR, QMap<QString, QString> (), QStringList(), \
projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), \
false, true, pCore->window());  +        connect(w.data(), \
&ProjectSettings::refreshProfiles, pCore->window(), \
&MainWindow::slotRefreshProfiles);  if (w->exec() != QDialog::Accepted) {
              delete w;
              return;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic