summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2010-10-08 04:23:33 (GMT)
committerMartin Jones <martin.jones@nokia.com>2010-10-08 04:23:33 (GMT)
commitebe12dbbda9c4f8921de010f21f3ede4e03942be (patch)
treefb701d007826adbf231620044fa11dec5661117f /src
parent762b03e1ae83ffd66965810e1d70326b364115f5 (diff)
parenta139b9aff0d658758cc7a8063377824178a8ea92 (diff)
downloadQt-ebe12dbbda9c4f8921de010f21f3ede4e03942be.zip
Qt-ebe12dbbda9c4f8921de010f21f3ede4e03942be.tar.gz
Qt-ebe12dbbda9c4f8921de010f21f3ede4e03942be.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
Diffstat (limited to 'src')
-rw-r--r--src/declarative/graphicsitems/qdeclarativetext.cpp4
-rw-r--r--src/declarative/qml/qdeclarativeengine.cpp26
-rw-r--r--src/declarative/qml/qdeclarativeglobal_p.h13
-rw-r--r--src/declarative/qml/qdeclarativeimport.cpp11
-rw-r--r--src/declarative/qml/qdeclarativetypeloader.cpp8
5 files changed, 59 insertions, 3 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativetext.cpp b/src/declarative/graphicsitems/qdeclarativetext.cpp
index 65f1564..54cb062 100644
--- a/src/declarative/graphicsitems/qdeclarativetext.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetext.cpp
@@ -82,7 +82,7 @@ private:
static QSet<QUrl> errors;
};
-DEFINE_BOOL_CONFIG_OPTION(disableImageCache, QML_DISABLE_IMAGE_CACHE);
+DEFINE_BOOL_CONFIG_OPTION(enableImageCache, QML_ENABLE_TEXT_IMAGE_CACHE);
QDeclarativeTextPrivate::QDeclarativeTextPrivate()
: color((QRgb)0), style(QDeclarativeText::Normal),
@@ -90,7 +90,7 @@ QDeclarativeTextPrivate::QDeclarativeTextPrivate()
imgDirty(true), dirty(true), richText(false), singleline(false), cache(true), internalWidthUpdate(false), doc(0),
format(QDeclarativeText::AutoText), wrapMode(QDeclarativeText::NoWrap)
{
- cache = !disableImageCache();
+ cache = enableImageCache();
QGraphicsItemPrivate::acceptedMouseButtons = Qt::LeftButton;
QGraphicsItemPrivate::flags = QGraphicsItemPrivate::flags & ~QGraphicsItem::ItemHasNoContents;
}
diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp
index 584c5ec..0749767 100644
--- a/src/declarative/qml/qdeclarativeengine.cpp
+++ b/src/declarative/qml/qdeclarativeengine.cpp
@@ -2159,4 +2159,30 @@ const QMetaObject *QDeclarativeEnginePrivate::metaObjectForType(int t) const
}
}
+bool QDeclarative_isFileCaseCorrect(const QString &fileName)
+{
+#if defined(Q_OS_MAC) || defined(Q_OS_WIN)
+ QFileInfo info(fileName);
+
+ QString absolute = info.absoluteFilePath();
+ QString canonical = info.canonicalFilePath();
+
+ int absoluteLength = absolute.length();
+ int canonicalLength = canonical.length();
+
+ 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);
+
+ if (a.toLower() != c.toLower())
+ return true;
+ if (a != c)
+ return false;
+ }
+#endif
+
+ return true;
+}
+
QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativeglobal_p.h b/src/declarative/qml/qdeclarativeglobal_p.h
index 1041992..65d9b24 100644
--- a/src/declarative/qml/qdeclarativeglobal_p.h
+++ b/src/declarative/qml/qdeclarativeglobal_p.h
@@ -75,6 +75,19 @@ struct QDeclarativeGraphics_DerivedObject : public QObject
};
/*!
+ Returns true if the case of \a fileName is equivalent to the file case of
+ \a fileName on disk, and false otherwise.
+
+ This is used to ensure that the behavior of QML on a case-insensitive file
+ system is the same as on a case-sensitive file system. This function
+ performs a "best effort" attempt to determine the real case of the file.
+ It may have false positives (say the case is correct when it isn't), but it
+ should never have a false negative (say the case is incorrect when it is
+ correct).
+*/
+bool QDeclarative_isFileCaseCorrect(const QString &fileName);
+
+/*!
Makes the \a object a child of \a parent. Note that when using this method,
neither \a parent nor the object's previous parent (if it had one) will
receive ChildRemoved or ChildAdded events.
diff --git a/src/declarative/qml/qdeclarativeimport.cpp b/src/declarative/qml/qdeclarativeimport.cpp
index fe4ed48..6f5216a 100644
--- a/src/declarative/qml/qdeclarativeimport.cpp
+++ b/src/declarative/qml/qdeclarativeimport.cpp
@@ -351,7 +351,11 @@ bool QDeclarativeImportsPrivate::importExtension(const QString &absoluteFilePath
{
QFile file(absoluteFilePath);
QString filecontent;
- if (file.open(QFile::ReadOnly)) {
+ if (!QDeclarative_isFileCaseCorrect(absoluteFilePath)) {
+ if (errorString)
+ *errorString = QDeclarativeImportDatabase::tr("cannot load module \"%1\": File name case mismatch for \"%2\"").arg(uri).arg(absoluteFilePath);
+ return false;
+ } else if (file.open(QFile::ReadOnly)) {
filecontent = QString::fromUtf8(file.readAll());
if (qmlImportTrace())
qDebug().nospace() << "QDeclarativeImports(" << qPrintable(base.toString()) << "::importExtension: "
@@ -913,6 +917,11 @@ bool QDeclarativeImportDatabase::importPlugin(const QString &filePath, const QSt
}
if (!engineInitialized || !typesRegistered) {
+ if (!QDeclarative_isFileCaseCorrect(absoluteFilePath)) {
+ if (errorString)
+ *errorString = tr("File name case mismatch for \"%2\"").arg(absoluteFilePath);
+ return false;
+ }
QPluginLoader loader(absoluteFilePath);
if (!loader.load()) {
diff --git a/src/declarative/qml/qdeclarativetypeloader.cpp b/src/declarative/qml/qdeclarativetypeloader.cpp
index 061f309..c8e1a07 100644
--- a/src/declarative/qml/qdeclarativetypeloader.cpp
+++ b/src/declarative/qml/qdeclarativetypeloader.cpp
@@ -44,6 +44,7 @@
#include <private/qdeclarativeengine_p.h>
#include <private/qdeclarativecompiler_p.h>
#include <private/qdeclarativecomponent_p.h>
+#include <private/qdeclarativeglobal_p.h>
#include <QtDeclarative/qdeclarativecomponent.h>
#include <QtCore/qdebug.h>
@@ -493,6 +494,13 @@ void QDeclarativeDataLoader::load(QDeclarativeDataBlob *blob)
QString lf = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(blob->m_url);
if (!lf.isEmpty()) {
+ if (!QDeclarative_isFileCaseCorrect(lf)) {
+ QDeclarativeError error;
+ error.setUrl(blob->m_url);
+ error.setDescription(QLatin1String("File name case mismatch"));
+ blob->setError(error);
+ return;
+ }
QFile file(lf);
if (file.open(QFile::ReadOnly)) {
QByteArray data = file.readAll();