QDeclarativeEngine: Polish code for file name case check.
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>
Thu, 5 Jan 2012 15:59:16 +0000 (16:59 +0100)
committerQt by Nokia <qt-info@nokia.com>
Fri, 6 Jan 2012 15:23:18 +0000 (16:23 +0100)
- Use Q_OS_WIN instead of Q_OS_WIN32
- const-correctness
- Use QString::fromWCharArray()

Change-Id: I67aa4bb69240cf187832ea456dd74d2909e7ae62
Reviewed-by: Kai Koehne <kai.koehne@nokia.com>
Reviewed-by: Aaron Kennedy <aaron.kennedy@nokia.com>
src/declarative/qml/qdeclarativeengine.cpp

index ba181a6..113abdc 100644 (file)
@@ -1790,14 +1790,13 @@ void QDeclarativeEnginePrivate::registerCompositeType(QDeclarativeCompiledData *
 
 bool QDeclarative_isFileCaseCorrect(const QString &fileName)
 {
-#if defined(Q_OS_MAC) || defined(Q_OS_WIN32)
+#if defined(Q_OS_MAC) || defined(Q_OS_WIN)
     QFileInfo info(fileName);
-
-    QString absolute = info.absoluteFilePath();
+    const QString absolute = info.absoluteFilePath();
 
 #if defined(Q_OS_MAC)
-    QString canonical = info.canonicalFilePath();
-#elif defined(Q_OS_WIN32)
+    const QString canonical = info.canonicalFilePath();
+#elif defined(Q_OS_WIN)
     wchar_t buffer[1024];
 
     DWORD rv = ::GetShortPathName((wchar_t*)absolute.utf16(), buffer, 1024);
@@ -1805,13 +1804,13 @@ bool QDeclarative_isFileCaseCorrect(const QString &fileName)
     rv = ::GetLongPathName(buffer, buffer, 1024);
     if (rv == 0 || rv >= 1024) return true;
 
-    QString canonical((QChar *)buffer);
+    const QString canonical = QString::fromWCharArray(buffer);
 #endif
 
-    int absoluteLength = absolute.length();
-    int canonicalLength = canonical.length();
+    const int absoluteLength = absolute.length();
+    const int canonicalLength = canonical.length();
 
-    int length = qMin(absoluteLength, canonicalLength);
+    const int length = qMin(absoluteLength, canonicalLength);
     for (int ii = 0; ii < length; ++ii) {
         const QChar &a = absolute.at(absoluteLength - 1 - ii);
         const QChar &c = canonical.at(canonicalLength - 1 - ii);