diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2011-02-14 08:29:21 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2011-02-14 08:29:21 (GMT) |
commit | 8fb224b87b4508d259f8348920caadc6a75c45e2 (patch) | |
tree | 76a9642f5c92e299c9c41031c52bd86730b6037f | |
parent | f1021208218aa1d7eda58fed2742ea6a99266153 (diff) | |
parent | 3bc6f8d8dd630cd0298e27fc4b7430d2bf73a232 (diff) | |
download | Qt-8fb224b87b4508d259f8348920caadc6a75c45e2.zip Qt-8fb224b87b4508d259f8348920caadc6a75c45e2.tar.gz Qt-8fb224b87b4508d259f8348920caadc6a75c45e2.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/qt-qml:
Don't leak ScopeChainNode's
Rename 'plugins\qmldebugging' (work around qmake issues)
Correct the "module not installed" error handling
Flickable uses the flick velocity to determine whether to retain grab
Make addImportPath() work for windows paths starting with lower case
Report any exceptions occurring in WorkerScript javascript code
MouseArea docs - link to onCanceled() from onReleased()
33 files changed, 494 insertions, 29 deletions
diff --git a/src/declarative/debugger/qdeclarativedebugserver.cpp b/src/declarative/debugger/qdeclarativedebugserver.cpp index a269984..ea3d9a3 100644 --- a/src/declarative/debugger/qdeclarativedebugserver.cpp +++ b/src/declarative/debugger/qdeclarativedebugserver.cpp @@ -118,7 +118,7 @@ QDeclarativeDebugServerConnection *QDeclarativeDebugServerPrivate::loadConnectio QStringList pluginCandidates; const QStringList paths = QCoreApplication::libraryPaths(); foreach (const QString &libPath, paths) { - const QDir dir(libPath + QLatin1String("/qmldebugging")); + const QDir dir(libPath + QLatin1String("/qmltooling")); if (dir.exists()) { QStringList plugins(dir.entryList(QDir::Files)); foreach (const QString &pluginPath, plugins) { diff --git a/src/declarative/graphicsitems/qdeclarativeflickable.cpp b/src/declarative/graphicsitems/qdeclarativeflickable.cpp index a12a5ed..8b2d094 100644 --- a/src/declarative/graphicsitems/qdeclarativeflickable.cpp +++ b/src/declarative/graphicsitems/qdeclarativeflickable.cpp @@ -53,6 +53,10 @@ QT_BEGIN_NAMESPACE // before we perform a flick. static const int FlickThreshold = 20; +// RetainGrabVelocity is the maxmimum instantaneous velocity that +// will ensure the Flickable retains the grab on consecutive flicks. +static const int RetainGrabVelocity = 15; + QDeclarativeFlickableVisibleArea::QDeclarativeFlickableVisibleArea(QDeclarativeFlickable *parent) : QObject(parent), flickable(parent), m_xPosition(0.), m_widthRatio(0.) , m_yPosition(0.), m_heightRatio(0.) @@ -672,7 +676,8 @@ void QDeclarativeFlickable::setFlickableDirection(FlickableDirection direction) void QDeclarativeFlickablePrivate::handleMousePressEvent(QGraphicsSceneMouseEvent *event) { Q_Q(QDeclarativeFlickable); - if (interactive && timeline.isActive() && (qAbs(hData.velocity) > 10 || qAbs(vData.velocity) > 10)) + if (interactive && timeline.isActive() + && (qAbs(hData.smoothVelocity.value()) > RetainGrabVelocity || qAbs(vData.smoothVelocity.value()) > RetainGrabVelocity)) stealMouse = true; // If we've been flicked then steal the click. else stealMouse = false; diff --git a/src/declarative/graphicsitems/qdeclarativemousearea.cpp b/src/declarative/graphicsitems/qdeclarativemousearea.cpp index ffbae3f..5b73a29 100644 --- a/src/declarative/graphicsitems/qdeclarativemousearea.cpp +++ b/src/declarative/graphicsitems/qdeclarativemousearea.cpp @@ -314,6 +314,8 @@ QDeclarativeMouseAreaPrivate::~QDeclarativeMouseAreaPrivate() position of the release of the click, and whether the click was held. The \e accepted property of the MouseEvent parameter is ignored in this handler. + + \sa onCanceled() */ /*! diff --git a/src/declarative/qml/qdeclarativeimport.cpp b/src/declarative/qml/qdeclarativeimport.cpp index 87183c4..7a1234d 100644 --- a/src/declarative/qml/qdeclarativeimport.cpp +++ b/src/declarative/qml/qdeclarativeimport.cpp @@ -457,6 +457,7 @@ bool QDeclarativeImportsPrivate::add(const QDeclarativeDirComponents &qmldircomp } QString url = uri; + bool versionFound = false; if (importType == QDeclarativeScriptParser::Import::Library) { url.replace(QLatin1Char('.'), QLatin1Char('/')); bool found = false; @@ -522,18 +523,18 @@ bool QDeclarativeImportsPrivate::add(const QDeclarativeDirComponents &qmldircomp } } - if (!found) { - found = QDeclarativeMetaType::isModule(uri.toUtf8(), vmaj, vmin); - if (!found) { - if (errorString) { - bool anyversion = QDeclarativeMetaType::isModule(uri.toUtf8(), -1, -1); - if (anyversion) - *errorString = QDeclarativeImportDatabase::tr("module \"%1\" version %2.%3 is not installed").arg(uri_arg).arg(vmaj).arg(vmin); - else - *errorString = QDeclarativeImportDatabase::tr("module \"%1\" is not installed").arg(uri_arg); - } - return false; + if (QDeclarativeMetaType::isModule(uri.toUtf8(), vmaj, vmin)) + versionFound = true; + + if (!versionFound && qmldircomponents.isEmpty()) { + if (errorString) { + bool anyversion = QDeclarativeMetaType::isModule(uri.toUtf8(), -1, -1); + if (anyversion) + *errorString = QDeclarativeImportDatabase::tr("module \"%1\" version %2.%3 is not installed").arg(uri_arg).arg(vmaj).arg(vmin); + else + *errorString = QDeclarativeImportDatabase::tr("module \"%1\" is not installed").arg(uri_arg); } + return false; } } else { @@ -578,7 +579,7 @@ bool QDeclarativeImportsPrivate::add(const QDeclarativeDirComponents &qmldircomp url.chop(1); } - if (vmaj > -1 && vmin > -1 && !qmldircomponents.isEmpty()) { + if (!versionFound && vmaj > -1 && vmin > -1 && !qmldircomponents.isEmpty()) { QList<QDeclarativeDirParser::Component>::ConstIterator it = qmldircomponents.begin(); int lowest_maj = INT_MAX; int lowest_min = INT_MAX; @@ -952,7 +953,8 @@ void QDeclarativeImportDatabase::addPluginPath(const QString& path) qDebug().nospace() << "QDeclarativeImportDatabase::addPluginPath: " << path; QUrl url = QUrl(path); - if (url.isRelative() || url.scheme() == QLatin1String("file")) { + if (url.isRelative() || url.scheme() == QLatin1String("file") + || (url.scheme().length() == 1 && QFile::exists(path)) ) { // windows path QDir dir = QDir(path); filePluginPath.prepend(dir.canonicalPath()); } else { @@ -974,7 +976,8 @@ void QDeclarativeImportDatabase::addImportPath(const QString& path) QUrl url = QUrl(path); QString cPath; - if (url.isRelative() || url.scheme() == QLatin1String("file")) { + if (url.isRelative() || url.scheme() == QLatin1String("file") + || (url.scheme().length() == 1 && QFile::exists(path)) ) { // windows path QDir dir = QDir(path); cPath = dir.canonicalPath(); } else { diff --git a/src/declarative/qml/qdeclarativeworkerscript.cpp b/src/declarative/qml/qdeclarativeworkerscript.cpp index 6283f92..f8d52b5 100644 --- a/src/declarative/qml/qdeclarativeworkerscript.cpp +++ b/src/declarative/qml/qdeclarativeworkerscript.cpp @@ -43,6 +43,7 @@ #include "private/qdeclarativelistmodel_p.h" #include "private/qdeclarativelistmodelworkeragent_p.h" #include "private/qdeclarativeengine_p.h" +#include "private/qdeclarativeexpression_p.h" #include <QtCore/qcoreevent.h> #include <QtCore/qcoreapplication.h> @@ -104,6 +105,19 @@ private: int m_id; }; +class WorkerErrorEvent : public QEvent +{ +public: + enum Type { WorkerError = WorkerRemoveEvent::WorkerRemove + 1 }; + + WorkerErrorEvent(const QDeclarativeError &error); + + QDeclarativeError error() const; + +private: + QDeclarativeError m_error; +}; + class QDeclarativeWorkerScriptEnginePrivate : public QObject { Q_OBJECT @@ -146,6 +160,7 @@ public: WorkerScript(); int id; + QUrl source; bool initialized; QDeclarativeWorkerScript *owner; QScriptValue object; @@ -173,6 +188,7 @@ protected: private: void processMessage(int, const QVariant &); void processLoad(int, const QUrl &); + void reportScriptException(WorkerScript *); }; QDeclarativeWorkerScriptEnginePrivate::QDeclarativeWorkerScriptEnginePrivate(QDeclarativeEngine *engine) @@ -273,6 +289,11 @@ void QDeclarativeWorkerScriptEnginePrivate::processMessage(int id, const QVarian args.setProperty(0, variantToScriptValue(data, workerEngine)); script->callback.call(script->object, args); + + if (workerEngine->hasUncaughtException()) { + reportScriptException(script); + workerEngine->clearExceptions(); + } } } @@ -286,7 +307,7 @@ void QDeclarativeWorkerScriptEnginePrivate::processLoad(int id, const QUrl &url) QFile f(fileName); if (f.open(QIODevice::ReadOnly)) { QByteArray data = f.readAll(); - QString script = QString::fromUtf8(data); + QString sourceCode = QString::fromUtf8(data); QScriptValue activation = getWorker(id); @@ -296,10 +317,19 @@ void QDeclarativeWorkerScriptEnginePrivate::processLoad(int id, const QUrl &url) ctxt->pushScope(urlContext); ctxt->pushScope(activation); ctxt->setActivationObject(activation); - QDeclarativeScriptParser::extractPragmas(script); + QDeclarativeScriptParser::extractPragmas(sourceCode); workerEngine->baseUrl = url; - workerEngine->evaluate(script); + workerEngine->evaluate(sourceCode); + + WorkerScript *script = workers.value(id); + if (script) { + script->source = url; + if (workerEngine->hasUncaughtException()) { + reportScriptException(script); + workerEngine->clearExceptions(); + } + } workerEngine->popContext(); } else { @@ -307,6 +337,22 @@ void QDeclarativeWorkerScriptEnginePrivate::processLoad(int id, const QUrl &url) } } +void QDeclarativeWorkerScriptEnginePrivate::reportScriptException(WorkerScript *script) +{ + if (!script || !workerEngine->hasUncaughtException()) + return; + + QDeclarativeError error; + QDeclarativeExpressionPrivate::exceptionToError(workerEngine, error); + error.setUrl(script->source); + + QDeclarativeWorkerScriptEnginePrivate *p = QDeclarativeWorkerScriptEnginePrivate::get(workerEngine); + + QMutexLocker(&p->m_lock); + if (script->owner) + QCoreApplication::postEvent(script->owner, new WorkerErrorEvent(error)); +} + QVariant QDeclarativeWorkerScriptEnginePrivate::scriptValueToVariant(const QScriptValue &value) { if (value.isBool()) { @@ -453,6 +499,16 @@ int WorkerRemoveEvent::workerId() const return m_id; } +WorkerErrorEvent::WorkerErrorEvent(const QDeclarativeError &error) +: QEvent((QEvent::Type)WorkerError), m_error(error) +{ +} + +QDeclarativeError WorkerErrorEvent::error() const +{ + return m_error; +} + QDeclarativeWorkerScriptEngine::QDeclarativeWorkerScriptEngine(QDeclarativeEngine *parent) : QThread(parent), d(new QDeclarativeWorkerScriptEnginePrivate(parent)) { @@ -682,6 +738,10 @@ bool QDeclarativeWorkerScript::event(QEvent *event) emit message(value); } return true; + } else if (event->type() == (QEvent::Type)WorkerErrorEvent::WorkerError) { + WorkerErrorEvent *workerEvent = static_cast<WorkerErrorEvent *>(event); + QDeclarativeEnginePrivate::warning(qmlEngine(this), workerEvent->error()); + return true; } else { return QObject::event(event); } diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro index 07825d9..afa0901 100644 --- a/src/plugins/plugins.pro +++ b/src/plugins/plugins.pro @@ -14,4 +14,4 @@ embedded:SUBDIRS *= gfxdrivers decorations mousedrivers kbddrivers symbian:SUBDIRS += s60 contains(QT_CONFIG, phonon): SUBDIRS *= phonon contains(QT_CONFIG, multimedia): SUBDIRS *= audio -contains(QT_CONFIG, declarative): SUBDIRS *= qmldebugging +contains(QT_CONFIG, declarative): SUBDIRS *= qmltooling diff --git a/src/plugins/qmldebugging/qmldebugging.pro b/src/plugins/qmltooling/qmltooling.pro index 01cf1a9..01cf1a9 100644 --- a/src/plugins/qmldebugging/qmldebugging.pro +++ b/src/plugins/qmltooling/qmltooling.pro diff --git a/src/plugins/qmldebugging/tcpserver/qtcpserverconnection.cpp b/src/plugins/qmltooling/tcpserver/qtcpserverconnection.cpp index 69c1ef5..69c1ef5 100644 --- a/src/plugins/qmldebugging/tcpserver/qtcpserverconnection.cpp +++ b/src/plugins/qmltooling/tcpserver/qtcpserverconnection.cpp diff --git a/src/plugins/qmldebugging/tcpserver/qtcpserverconnection.h b/src/plugins/qmltooling/tcpserver/qtcpserverconnection.h index a6e17e6..a6e17e6 100644 --- a/src/plugins/qmldebugging/tcpserver/qtcpserverconnection.h +++ b/src/plugins/qmltooling/tcpserver/qtcpserverconnection.h diff --git a/src/plugins/qmldebugging/tcpserver/tcpserver.pro b/src/plugins/qmltooling/tcpserver/tcpserver.pro index e90fb34..f4f2666 100644 --- a/src/plugins/qmldebugging/tcpserver/tcpserver.pro +++ b/src/plugins/qmltooling/tcpserver/tcpserver.pro @@ -3,7 +3,7 @@ QT += declarative network include(../../qpluginbase.pri) -QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/qmldebugging +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/qmltooling QTDIR_build:REQUIRES += "contains(QT_CONFIG, declarative)" SOURCES += \ @@ -12,7 +12,7 @@ SOURCES += \ HEADERS += \ qtcpserverconnection.h -target.path += $$[QT_INSTALL_PLUGINS]/qmldebugging +target.path += $$[QT_INSTALL_PLUGINS]/qmltooling INSTALLS += target symbian:TARGET.UID3=0x20031E90
\ No newline at end of file diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp index 478fdaa..d3e5f2f 100644 --- a/src/script/api/qscriptengine.cpp +++ b/src/script/api/qscriptengine.cpp @@ -2762,9 +2762,7 @@ JSC::CallFrame *QScriptEnginePrivate::pushContext(JSC::CallFrame *exec, JSC::JSV if (!clearScopeChain) { newCallFrame->init(0, /*vPC=*/0, exec->scopeChain(), exec, flags | ShouldRestoreCallFrame, argc, callee); } else { - JSC::JSObject *jscObject = originalGlobalObject(); - JSC::ScopeChainNode *scn = new JSC::ScopeChainNode(0, jscObject, &exec->globalData(), exec->lexicalGlobalObject(), jscObject); - newCallFrame->init(0, /*vPC=*/0, scn, exec, flags | ShouldRestoreCallFrame, argc, callee); + newCallFrame->init(0, /*vPC=*/0, globalExec()->scopeChain(), exec, flags | ShouldRestoreCallFrame, argc, callee); } } else { setContextFlags(newCallFrame, flags); diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp index b19b3c9..40b0e1b 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -50,6 +50,7 @@ #include <QtCore/qnumeric.h> #include <private/qdeclarativeengine_p.h> #include <private/qdeclarativeglobalscriptclass_p.h> +#include <private/qscriptdeclarativeclass_p.h> #include "testtypes.h" #include "testhttpserver.h" #include "../../../shared/util.h" @@ -174,6 +175,7 @@ private slots: void aliasBindingsAssignCorrectly(); void aliasBindingsOverrideTarget(); void aliasWritesOverrideBindings(); + void pushCleanContext(); void include(); @@ -3015,6 +3017,44 @@ void tst_qdeclarativeecmascript::revision() } } +// Test for QScriptDeclarativeClass::pushCleanContext() +void tst_qdeclarativeecmascript::pushCleanContext() +{ + QScriptEngine engine; + engine.globalObject().setProperty("a", 6); + QCOMPARE(engine.evaluate("a").toInt32(), 6); + + // First confirm pushContext() behaves as we expect + QScriptValue object = engine.newObject(); + object.setProperty("a", 15); + QScriptContext *context1 = engine.pushContext(); + context1->pushScope(object); + QCOMPARE(engine.evaluate("a").toInt32(), 15); + + QScriptContext *context2 = engine.pushContext(); + Q_UNUSED(context2); + QCOMPARE(engine.evaluate("a").toInt32(), 15); + QScriptValue func1 = engine.evaluate("(function() { return a; })"); + + // Now check that pushCleanContext() works + QScriptDeclarativeClass::pushCleanContext(&engine); + QCOMPARE(engine.evaluate("a").toInt32(), 6); + QScriptValue func2 = engine.evaluate("(function() { return a; })"); + + engine.popContext(); + QCOMPARE(engine.evaluate("a").toInt32(), 15); + + engine.popContext(); + QCOMPARE(engine.evaluate("a").toInt32(), 15); + + engine.popContext(); + QCOMPARE(engine.evaluate("a").toInt32(), 6); + + // Check that function objects created in these contexts work + QCOMPARE(func1.call().toInt32(), 15); + QCOMPARE(func2.call().toInt32(), 6); +} + QTEST_MAIN(tst_qdeclarativeecmascript) #include "tst_qdeclarativeecmascript.moc" diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/data/importsMixedQmlCppPlugin.2.qml b/tests/auto/declarative/qdeclarativemoduleplugin/data/importsMixedQmlCppPlugin.2.qml new file mode 100644 index 0000000..70b2bfd --- /dev/null +++ b/tests/auto/declarative/qdeclarativemoduleplugin/data/importsMixedQmlCppPlugin.2.qml @@ -0,0 +1,21 @@ +import com.nokia.AutoTestQmlMixedPluginType 1.5 +import QtQuick 1.0 + +Item { + property bool test: false + property bool test2: false + + Bar { + id: bar + } + + Foo { + id: foo + } + + Component.onCompleted: { + test = (bar.value == 16); + test2 = (foo.value == 89); + } +} + diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/data/importsMixedQmlCppPlugin.qml b/tests/auto/declarative/qdeclarativemoduleplugin/data/importsMixedQmlCppPlugin.qml new file mode 100644 index 0000000..da6ff46 --- /dev/null +++ b/tests/auto/declarative/qdeclarativemoduleplugin/data/importsMixedQmlCppPlugin.qml @@ -0,0 +1,13 @@ +import com.nokia.AutoTestQmlMixedPluginType 1.0 +import QtQuick 1.0 + +Item { + property bool test: false + Bar { + id: bar + } + + Component.onCompleted: { + test = (bar.value == 16); + } +} diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/data/versionNotInstalled.2.errors.txt b/tests/auto/declarative/qdeclarativemoduleplugin/data/versionNotInstalled.2.errors.txt new file mode 100644 index 0000000..a40c1c8 --- /dev/null +++ b/tests/auto/declarative/qdeclarativemoduleplugin/data/versionNotInstalled.2.errors.txt @@ -0,0 +1 @@ +1:1:module "com.nokia.AutoTestQmlVersionPluginType" version 1.9 is not installed diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/data/versionNotInstalled.2.qml b/tests/auto/declarative/qdeclarativemoduleplugin/data/versionNotInstalled.2.qml new file mode 100644 index 0000000..59fd084 --- /dev/null +++ b/tests/auto/declarative/qdeclarativemoduleplugin/data/versionNotInstalled.2.qml @@ -0,0 +1,5 @@ +import com.nokia.AutoTestQmlVersionPluginType 1.9 +import QtQuick 1.0 + +QtObject { +} diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/data/versionNotInstalled.errors.txt b/tests/auto/declarative/qdeclarativemoduleplugin/data/versionNotInstalled.errors.txt new file mode 100644 index 0000000..2634223 --- /dev/null +++ b/tests/auto/declarative/qdeclarativemoduleplugin/data/versionNotInstalled.errors.txt @@ -0,0 +1 @@ +1:1:module "com.nokia.AutoTestQmlVersionPluginType" version 1.1 is not installed diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/data/versionNotInstalled.qml b/tests/auto/declarative/qdeclarativemoduleplugin/data/versionNotInstalled.qml new file mode 100644 index 0000000..2065c07 --- /dev/null +++ b/tests/auto/declarative/qdeclarativemoduleplugin/data/versionNotInstalled.qml @@ -0,0 +1,6 @@ +import com.nokia.AutoTestQmlVersionPluginType 1.1 +import QtQuick 1.0 + +QtObject { +} + diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestQmlMixedPluginType/Foo.qml b/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestQmlMixedPluginType/Foo.qml new file mode 100644 index 0000000..ce51cbd --- /dev/null +++ b/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestQmlMixedPluginType/Foo.qml @@ -0,0 +1,5 @@ +import QtQuick 1.0 + +Item { + property int value: 89 +} diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestQmlMixedPluginType/qmldir b/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestQmlMixedPluginType/qmldir new file mode 100644 index 0000000..065dc3b --- /dev/null +++ b/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestQmlMixedPluginType/qmldir @@ -0,0 +1,2 @@ +plugin pluginMixed +Foo 1.5 Foo.qml diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestQmlVersionPluginType/qmldir b/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestQmlVersionPluginType/qmldir new file mode 100644 index 0000000..640967f --- /dev/null +++ b/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestQmlVersionPluginType/qmldir @@ -0,0 +1 @@ +plugin pluginVersion diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/pluginMixed/plugin.cpp b/tests/auto/declarative/qdeclarativemoduleplugin/pluginMixed/plugin.cpp new file mode 100644 index 0000000..c7796e2 --- /dev/null +++ b/tests/auto/declarative/qdeclarativemoduleplugin/pluginMixed/plugin.cpp @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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 BarPluginType : public QObject +{ + Q_OBJECT + Q_PROPERTY(int value READ value); + +public: + int value() const { return 16; } +}; + + +class MyMixedPlugin : public QDeclarativeExtensionPlugin +{ + Q_OBJECT +public: + MyMixedPlugin() + { + } + + void registerTypes(const char *uri) + { + Q_ASSERT(QLatin1String(uri) == "com.nokia.AutoTestQmlMixedPluginType"); + qmlRegisterType<BarPluginType>(uri, 1, 0, "Bar"); + } +}; + +#include "plugin.moc" + +Q_EXPORT_PLUGIN2(plugin, MyMixedPlugin); diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/pluginMixed/pluginMixed.pro b/tests/auto/declarative/qdeclarativemoduleplugin/pluginMixed/pluginMixed.pro new file mode 100644 index 0000000..9766003 --- /dev/null +++ b/tests/auto/declarative/qdeclarativemoduleplugin/pluginMixed/pluginMixed.pro @@ -0,0 +1,9 @@ +TEMPLATE = lib +CONFIG += plugin +SOURCES = plugin.cpp +QT = core declarative +DESTDIR = ../imports/com/nokia/AutoTestQmlMixedPluginType + +symbian: { + TARGET.EPOCALLOWDLLDATA=1 +} diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/pluginVersion/plugin.cpp b/tests/auto/declarative/qdeclarativemoduleplugin/pluginVersion/plugin.cpp new file mode 100644 index 0000000..27a6341 --- /dev/null +++ b/tests/auto/declarative/qdeclarativemoduleplugin/pluginVersion/plugin.cpp @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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 FloorPluginType : public QObject +{ + Q_OBJECT + Q_PROPERTY(int value READ value); + +public: + int value() const { return 16; } +}; + + +class MyMixedPlugin : public QDeclarativeExtensionPlugin +{ + Q_OBJECT +public: + MyMixedPlugin() + { + } + + void registerTypes(const char *uri) + { + Q_ASSERT(QLatin1String(uri) == "com.nokia.AutoTestQmlVersionPluginType"); + qmlRegisterType<FloorPluginType>(uri, 1, 4, "Floor"); + } +}; + +#include "plugin.moc" + +Q_EXPORT_PLUGIN2(plugin, MyMixedPlugin); diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/pluginVersion/pluginVersion.pro b/tests/auto/declarative/qdeclarativemoduleplugin/pluginVersion/pluginVersion.pro new file mode 100644 index 0000000..70a38b9 --- /dev/null +++ b/tests/auto/declarative/qdeclarativemoduleplugin/pluginVersion/pluginVersion.pro @@ -0,0 +1,9 @@ +TEMPLATE = lib +CONFIG += plugin +SOURCES = plugin.cpp +QT = core declarative +DESTDIR = ../imports/com/nokia/AutoTestQmlVersionPluginType + +symbian: { + TARGET.EPOCALLOWDLLDATA=1 +} diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/qdeclarativemoduleplugin.pro b/tests/auto/declarative/qdeclarativemoduleplugin/qdeclarativemoduleplugin.pro index 9d0e94e..6e72d98 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 plugin.2 plugin.2.1 pluginWrongCase pluginWithQmlFile +SUBDIRS = plugin plugin.2 plugin.2.1 pluginWrongCase pluginWithQmlFile pluginMixed pluginVersion 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 9ec0f84..dc104e2 100644 --- a/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp +++ b/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp @@ -63,10 +63,13 @@ private slots: void importsPlugin(); void importsPlugin2(); void importsPlugin21(); + void importsMixedQmlCppPlugin(); void incorrectPluginCase(); void importPluginWithQmlFile(); void remoteImportWithQuotedUrl(); void remoteImportWithUnquotedUri(); + void versionNotInstalled(); + void versionNotInstalled_data(); }; #ifdef Q_OS_SYMBIAN @@ -191,8 +194,18 @@ void tst_qdeclarativemoduleplugin::incorrectPluginCase() void tst_qdeclarativemoduleplugin::importPluginWithQmlFile() { + QString path = QLatin1String(SRCDIR) + QDir::separator() + QLatin1String("imports"); + + // QTBUG-16885: adding an import path with a lower-case "c:" causes assert failure + // (this only happens if the plugin includes pure QML files) + #ifdef Q_OS_WIN + QVERIFY(path.at(0).isUpper() && path.at(1) == QLatin1Char(':')); + path = path.at(0).toLower() + path.mid(1); + #endif + QDeclarativeEngine engine; - engine.addImportPath(QLatin1String(SRCDIR) + QDir::separator() + QLatin1String("imports")); + engine.addImportPath(path); + QDeclarativeComponent component(&engine, TEST_FILE("data/pluginWithQmlFile.qml")); foreach (QDeclarativeError err, component.errors()) qWarning() << err; @@ -246,6 +259,55 @@ void tst_qdeclarativemoduleplugin::remoteImportWithUnquotedUri() VERIFY_ERRORS(0); } +// QTBUG-17324 +void tst_qdeclarativemoduleplugin::importsMixedQmlCppPlugin() +{ + QDeclarativeEngine engine; + engine.addImportPath(QLatin1String(SRCDIR) + QDir::separator() + QLatin1String("imports")); + + { + QDeclarativeComponent component(&engine, TEST_FILE("data/importsMixedQmlCppPlugin.qml")); + + QObject *o = component.create(); + QVERIFY(o != 0); + QCOMPARE(o->property("test").toBool(), true); + delete o; + } + + { + QDeclarativeComponent component(&engine, TEST_FILE("data/importsMixedQmlCppPlugin.2.qml")); + + QObject *o = component.create(); + QVERIFY(o != 0); + QCOMPARE(o->property("test").toBool(), true); + QCOMPARE(o->property("test2").toBool(), true); + delete o; + } + + +} + +void tst_qdeclarativemoduleplugin::versionNotInstalled_data() +{ + QTest::addColumn<QString>("file"); + QTest::addColumn<QString>("errorFile"); + + QTest::newRow("versionNotInstalled") << "data/versionNotInstalled.qml" << "versionNotInstalled.errors.txt"; + QTest::newRow("versionNotInstalled") << "data/versionNotInstalled.2.qml" << "versionNotInstalled.2.errors.txt"; +} + +void tst_qdeclarativemoduleplugin::versionNotInstalled() +{ + QFETCH(QString, file); + QFETCH(QString, errorFile); + + QDeclarativeEngine engine; + engine.addImportPath(QLatin1String(SRCDIR) + QDir::separator() + QLatin1String("imports")); + + QDeclarativeComponent component(&engine, TEST_FILE(file)); + VERIFY_ERRORS(errorFile.toLatin1().constData()); +} + QTEST_MAIN(tst_qdeclarativemoduleplugin) #include "tst_qdeclarativemoduleplugin.moc" diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/script_error_onCall.js b/tests/auto/declarative/qdeclarativeworkerscript/data/script_error_onCall.js new file mode 100644 index 0000000..f589b0e --- /dev/null +++ b/tests/auto/declarative/qdeclarativeworkerscript/data/script_error_onCall.js @@ -0,0 +1,6 @@ +WorkerScript.onMessage = function(msg) { + var a = 123 + var b = 345 + var f = getData() +} + diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/script_error_onLoad.js b/tests/auto/declarative/qdeclarativeworkerscript/data/script_error_onLoad.js new file mode 100644 index 0000000..1d6eab2 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeworkerscript/data/script_error_onLoad.js @@ -0,0 +1,5 @@ +WorkerScript.onMessage = function(msg) { + var a = 123 + aoij awef aljfaow eij +} + diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/worker_error_onCall.qml b/tests/auto/declarative/qdeclarativeworkerscript/data/worker_error_onCall.qml new file mode 100644 index 0000000..90c4617 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeworkerscript/data/worker_error_onCall.qml @@ -0,0 +1,6 @@ +import QtQuick 1.0 + +BaseWorker { + source: "script_error_onCall.js" +} + diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/worker_error_onLoad.qml b/tests/auto/declarative/qdeclarativeworkerscript/data/worker_error_onLoad.qml new file mode 100644 index 0000000..0b9d21d --- /dev/null +++ b/tests/auto/declarative/qdeclarativeworkerscript/data/worker_error_onLoad.qml @@ -0,0 +1,7 @@ +import QtQuick 1.0 + +BaseWorker { + source: "script_error_onLoad.js" +} + + diff --git a/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp b/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp index aaedd82..4b922fb 100644 --- a/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp +++ b/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp @@ -41,6 +41,8 @@ #include <qtest.h> #include <QtCore/qdebug.h> #include <QtCore/qtimer.h> +#include <QtCore/qdir.h> +#include <QtCore/qfileinfo.h> #include <QtScript/qscriptengine.h> #include <QtDeclarative/qdeclarativecomponent.h> @@ -58,6 +60,13 @@ Q_DECLARE_METATYPE(QScriptValue) #define SRCDIR "." #endif +inline QUrl TEST_FILE(const QString &filename) +{ + QFileInfo fileInfo(__FILE__); + return QUrl::fromLocalFile(fileInfo.absoluteDir().filePath(filename)); +} + + class tst_QDeclarativeWorkerScript : public QObject { Q_OBJECT @@ -70,6 +79,8 @@ private slots: void messaging_sendQObjectList(); void messaging_sendJsObject(); void script_with_pragma(); + void scriptError_onLoad(); + void scriptError_onCall(); private: void waitForEchoMessage(QDeclarativeWorkerScript *worker) { @@ -215,6 +226,47 @@ void tst_QDeclarativeWorkerScript::script_with_pragma() delete worker; } +static QString qdeclarativeworkerscript_lastWarning; +static void qdeclarativeworkerscript_warningsHandler(QtMsgType type, const char *msg) +{ + if (type == QtWarningMsg) + qdeclarativeworkerscript_lastWarning = QString::fromUtf8(msg); +} + +void tst_QDeclarativeWorkerScript::scriptError_onLoad() +{ + QDeclarativeComponent component(&m_engine, SRCDIR "/data/worker_error_onLoad.qml"); + + QtMsgHandler previousMsgHandler = qInstallMsgHandler(qdeclarativeworkerscript_warningsHandler); + QDeclarativeWorkerScript *worker = qobject_cast<QDeclarativeWorkerScript*>(component.create()); + QVERIFY(worker != 0); + + QTRY_COMPARE(qdeclarativeworkerscript_lastWarning, + TEST_FILE("data/script_error_onLoad.js").toString() + QLatin1String(":3: SyntaxError: Parse error")); + + qInstallMsgHandler(previousMsgHandler); + qApp->processEvents(); + delete worker; +} + +void tst_QDeclarativeWorkerScript::scriptError_onCall() +{ + QDeclarativeComponent component(&m_engine, SRCDIR "/data/worker_error_onCall.qml"); + QDeclarativeWorkerScript *worker = qobject_cast<QDeclarativeWorkerScript*>(component.create()); + QVERIFY(worker != 0); + + QtMsgHandler previousMsgHandler = qInstallMsgHandler(qdeclarativeworkerscript_warningsHandler); + QVariant value; + QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, value))); + + QTRY_COMPARE(qdeclarativeworkerscript_lastWarning, + TEST_FILE("data/script_error_onCall.js").toString() + QLatin1String(":4: ReferenceError: Can't find variable: getData")); + + qInstallMsgHandler(previousMsgHandler); + qApp->processEvents(); + delete worker; +} + QTEST_MAIN(tst_QDeclarativeWorkerScript) diff --git a/tools/qml/qml.pro b/tools/qml/qml.pro index 5d6192d..b1d56ea 100644 --- a/tools/qml/qml.pro +++ b/tools/qml/qml.pro @@ -39,8 +39,8 @@ symbian { TARGET.CAPABILITY = NetworkServices ReadUserData # Deploy plugin for remote debugging - qmldebuggingplugin.sources = $$QT_BUILD_TREE/plugins/qmldebugging/tcpserver$${QT_LIBINFIX}.dll - qmldebuggingplugin.path = c:$$QT_PLUGINS_BASE_DIR/qmldebugging + qmldebuggingplugin.sources = $$QT_BUILD_TREE/plugins/qmltooling/tcpserver$${QT_LIBINFIX}.dll + qmldebuggingplugin.path = c:$$QT_PLUGINS_BASE_DIR/qmltooling DEPLOYMENT += qmldebuggingplugin } mac { |