diff options
author | Friedemann Kleint <Friedemann.Kleint@nokia.com> | 2012-01-05 16:59:16 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-01-06 16:23:18 +0100 |
commit | dd8fb8bccfcb5fb50865ad7e1d33fa181954d254 (patch) | |
tree | 3a92432ce4ee53e2794b8751aedc64d44e736b6e | |
parent | 72ae9e8396bce07c020623c99a7a6780cb38e7ca (diff) |
QDeclarativeEngine: Polish code for file name case check.
- 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>
-rw-r--r-- | src/declarative/qml/qdeclarativeengine.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index ba181a6fc7..113abdcecc 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -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); |