summaryrefslogtreecommitdiffstats
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
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
-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
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/importIncorrectCase.qml5
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/incorrectCase.errors.insensitive.txt2
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/incorrectCase.errors.sensitive.txt1
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/incorrectCase.qml4
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/incorrectCaseType.qml4
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp24
-rw-r--r--tests/auto/declarative/qdeclarativemoduleplugin/data/incorrectCase.qml4
-rw-r--r--tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/WrongCase/qmldir1
-rw-r--r--tests/auto/declarative/qdeclarativemoduleplugin/pluginWrongCase/plugin.cpp83
-rw-r--r--tests/auto/declarative/qdeclarativemoduleplugin/pluginWrongCase/pluginWrongCase.pro10
-rw-r--r--tests/auto/declarative/qdeclarativemoduleplugin/qdeclarativemoduleplugin.pro2
-rw-r--r--tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp20
17 files changed, 218 insertions, 4 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();
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importIncorrectCase.qml b/tests/auto/declarative/qdeclarativelanguage/data/importIncorrectCase.qml
new file mode 100644
index 0000000..247f527
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/importIncorrectCase.qml
@@ -0,0 +1,5 @@
+import QtQuick 1.0
+import com.Nokia.installedtest 1.0
+
+QtObject {
+}
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/incorrectCase.errors.insensitive.txt b/tests/auto/declarative/qdeclarativelanguage/data/incorrectCase.errors.insensitive.txt
new file mode 100644
index 0000000..3813680
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/incorrectCase.errors.insensitive.txt
@@ -0,0 +1,2 @@
+3:1:Type IncorrectCaseType unavailable
+-1:-1:File name case mismatch
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/incorrectCase.errors.sensitive.txt b/tests/auto/declarative/qdeclarativelanguage/data/incorrectCase.errors.sensitive.txt
new file mode 100644
index 0000000..abed1a7
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/incorrectCase.errors.sensitive.txt
@@ -0,0 +1 @@
+3:1:IncorrectCaseType is not a type
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/incorrectCase.qml b/tests/auto/declarative/qdeclarativelanguage/data/incorrectCase.qml
new file mode 100644
index 0000000..d11000b
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/incorrectCase.qml
@@ -0,0 +1,4 @@
+import QtQuick 1.0
+
+IncorrectCaseType {
+}
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/incorrectCaseType.qml b/tests/auto/declarative/qdeclarativelanguage/data/incorrectCaseType.qml
new file mode 100644
index 0000000..cf32b45
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/incorrectCaseType.qml
@@ -0,0 +1,4 @@
+import QtQuick 1.0
+
+QtObject {
+}
diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
index bb1312b..2aac27e 100644
--- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
+++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
@@ -144,6 +144,7 @@ private slots:
void importsInstalled();
void importsOrder_data();
void importsOrder();
+ void importIncorrectCase();
void qmlAttachedPropertiesObjectMethod();
void customOnProperty();
@@ -382,6 +383,13 @@ void tst_qdeclarativelanguage::errors_data()
QTest::newRow("notAvailable") << "notAvailable.qml" << "notAvailable.errors.txt" << false;
QTest::newRow("singularProperty") << "singularProperty.qml" << "singularProperty.errors.txt" << false;
QTest::newRow("singularProperty.2") << "singularProperty.2.qml" << "singularProperty.2.errors.txt" << false;
+ QTest::newRow("incorrectCase") << "incorrectCase.qml"
+#if defined(Q_OS_MAC) || defined(Q_OS_WIN)
+ << "incorrectCase.errors.insensitive.txt"
+#else
+ << "incorrectCase.errors.sensitive.txt"
+#endif
+ << false;
}
@@ -1724,6 +1732,22 @@ void tst_qdeclarativelanguage::importsOrder()
testType(qml,type,error);
}
+void tst_qdeclarativelanguage::importIncorrectCase()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("importIncorrectCase.qml"));
+
+ QList<QDeclarativeError> errors = component.errors();
+ QCOMPARE(errors.count(), 1);
+
+#if defined(Q_OS_MAC) || defined(Q_OS_WIN)
+ QString expectedError = QLatin1String("cannot load module \"com.Nokia.installedtest\": File name case mismatch for \"") + QFileInfo(__FILE__).absoluteDir().filePath("data/lib/com/Nokia/installedtest/qmldir") + QLatin1String("\"");
+#else
+ QString expectedError = QLatin1String("module \"com.Nokia.installedtest\" is not installed");
+#endif
+
+ QCOMPARE(errors.at(0).description(), expectedError);
+}
+
void tst_qdeclarativelanguage::qmlAttachedPropertiesObjectMethod()
{
QObject object;
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/data/incorrectCase.qml b/tests/auto/declarative/qdeclarativemoduleplugin/data/incorrectCase.qml
new file mode 100644
index 0000000..a21ece7
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativemoduleplugin/data/incorrectCase.qml
@@ -0,0 +1,4 @@
+import com.nokia.WrongCase 1.0
+
+MyPluginType { value: 123 }
+
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/WrongCase/qmldir b/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/WrongCase/qmldir
new file mode 100644
index 0000000..6c87874
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/WrongCase/qmldir
@@ -0,0 +1 @@
+plugin PluGin
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/pluginWrongCase/plugin.cpp b/tests/auto/declarative/qdeclarativemoduleplugin/pluginWrongCase/plugin.cpp
new file mode 100644
index 0000000..5e91f4e
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativemoduleplugin/pluginWrongCase/plugin.cpp
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QStringList>
+#include <QtDeclarative/qdeclarativeextensionplugin.h>
+#include <QtDeclarative/qdeclarative.h>
+#include <QDebug>
+
+class MyPluginType : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int value READ value WRITE setValue)
+
+public:
+ MyPluginType(QObject *parent=0) : QObject(parent)
+ {
+ qWarning("import worked");
+ }
+
+ int value() const { return v; }
+ void setValue(int i) { v = i; }
+
+private:
+ int v;
+};
+
+
+class MyPlugin : public QDeclarativeExtensionPlugin
+{
+ Q_OBJECT
+public:
+ MyPlugin()
+ {
+ qWarning("plugin created");
+ }
+
+ void registerTypes(const char *uri)
+ {
+ Q_ASSERT(QLatin1String(uri) == "com.nokia.WrongCase");
+ qmlRegisterType<MyPluginType>(uri, 1, 0, "MyPluginType");
+ }
+};
+
+#include "plugin.moc"
+
+Q_EXPORT_PLUGIN2(plugin, MyPlugin);
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/pluginWrongCase/pluginWrongCase.pro b/tests/auto/declarative/qdeclarativemoduleplugin/pluginWrongCase/pluginWrongCase.pro
new file mode 100644
index 0000000..c7337ca
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativemoduleplugin/pluginWrongCase/pluginWrongCase.pro
@@ -0,0 +1,10 @@
+TEMPLATE = lib
+CONFIG += plugin
+SOURCES = plugin.cpp
+QT = core declarative
+TARGET = Plugin
+DESTDIR = ../imports/com/nokia/WrongCase
+
+symbian: {
+ TARGET.EPOCALLOWDLLDATA=1
+}
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/qdeclarativemoduleplugin.pro b/tests/auto/declarative/qdeclarativemoduleplugin/qdeclarativemoduleplugin.pro
index 824b402..221e465 100644
--- a/tests/auto/declarative/qdeclarativemoduleplugin/qdeclarativemoduleplugin.pro
+++ b/tests/auto/declarative/qdeclarativemoduleplugin/qdeclarativemoduleplugin.pro
@@ -1,6 +1,6 @@
QT = core
TEMPLATE = subdirs
-SUBDIRS = plugin
+SUBDIRS = plugin pluginWrongCase
tst_qdeclarativemoduleplugin_pro.depends += plugin
SUBDIRS += tst_qdeclarativemoduleplugin.pro
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp b/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp
index e1022e0..587a86a 100644
--- a/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp
+++ b/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp
@@ -54,6 +54,7 @@ public:
private slots:
void importsPlugin();
+ void incorrectPluginCase();
};
#ifdef Q_OS_SYMBIAN
@@ -120,6 +121,25 @@ void tst_qdeclarativemoduleplugin::importsPlugin()
delete object;
}
+void tst_qdeclarativemoduleplugin::incorrectPluginCase()
+{
+ QDeclarativeEngine engine;
+ engine.addImportPath(QLatin1String(SRCDIR) + QDir::separator() + QLatin1String("imports"));
+
+ QDeclarativeComponent component(&engine, TEST_FILE("data/incorrectCase.qml"));
+
+ QList<QDeclarativeError> errors = component.errors();
+ QCOMPARE(errors.count(), 1);
+
+#if defined(Q_OS_MAC) || defined(Q_OS_WIN)
+ QString expectedError = QLatin1String("plugin cannot be loaded for module \"com.nokia.WrongCase\": File name case mismatch for \"") + QFileInfo(__FILE__).absoluteDir().filePath("imports/com/nokia/WrongCase/libPluGin.dylib") + QLatin1String("\"");
+#else
+ QString expectedError = QLatin1String("module \"com.nokia.WrongCase\" plugin \"PluGin\" not found");
+#endif
+
+ QCOMPARE(errors.at(0).description(), expectedError);
+}
+
QTEST_MAIN(tst_qdeclarativemoduleplugin)
#include "tst_qdeclarativemoduleplugin.moc"