From abd0103ef31b1aad5bfa0e75ee0270d9342c92e7 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Thu, 10 Feb 2011 12:53:33 +1000 Subject: MouseArea docs - link to onCanceled() from onReleased() --- src/declarative/graphicsitems/qdeclarativemousearea.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/declarative/graphicsitems/qdeclarativemousearea.cpp b/src/declarative/graphicsitems/qdeclarativemousearea.cpp index 273fc53..0aa0c1b 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() */ /*! -- cgit v0.12 From 974db3ce58307069fcafdee2c5636ff72b061134 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Thu, 10 Feb 2011 15:31:17 +1000 Subject: Report any exceptions occurring in WorkerScript javascript code Task-number: QTBUG-17183 Change-Id: I709cca0bdce247ca9250c4f334654e2ff57b0b32 Reviewed-by: Aaron Kennedy --- src/declarative/qml/qdeclarativeworkerscript.cpp | 66 +++++++++++++++++++++- .../data/script_error_onCall.js | 6 ++ .../data/script_error_onLoad.js | 5 ++ .../data/worker_error_onCall.qml | 6 ++ .../data/worker_error_onLoad.qml | 7 +++ .../tst_qdeclarativeworkerscript.cpp | 52 +++++++++++++++++ 6 files changed, 139 insertions(+), 3 deletions(-) create mode 100644 tests/auto/declarative/qdeclarativeworkerscript/data/script_error_onCall.js create mode 100644 tests/auto/declarative/qdeclarativeworkerscript/data/script_error_onLoad.js create mode 100644 tests/auto/declarative/qdeclarativeworkerscript/data/worker_error_onCall.qml create mode 100644 tests/auto/declarative/qdeclarativeworkerscript/data/worker_error_onLoad.qml diff --git a/src/declarative/qml/qdeclarativeworkerscript.cpp b/src/declarative/qml/qdeclarativeworkerscript.cpp index ac13c68..9721389 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 #include @@ -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)) { @@ -687,6 +743,10 @@ bool QDeclarativeWorkerScript::event(QEvent *event) emit message(value); } return true; + } else if (event->type() == (QEvent::Type)WorkerErrorEvent::WorkerError) { + WorkerErrorEvent *workerEvent = static_cast(event); + QDeclarativeEnginePrivate::warning(qmlEngine(this), workerEvent->error()); + return true; } else { return QObject::event(event); } 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 #include #include +#include +#include #include #include @@ -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(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(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) -- cgit v0.12 From 33512bc223be373975426ffcc6f8fa783a7582c9 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Fri, 11 Feb 2011 11:33:37 +1000 Subject: Make addImportPath() work for windows paths starting with lower case Was causing assert failure on windows if the 'c:' was lower case, since it was being added to the import path database with a lower case and thus later lookups with an upper case 'c:' would fail. This change fixes the check for whether the path refers to a local path or not. Task-number: QTBUG-16885 Change-Id: I0a2a2f705443ed453fb2b13f8599e035c2bd2877 Reviewed-by: Martin Jones --- src/declarative/qml/qdeclarativeimport.cpp | 6 ++++-- .../tst_qdeclarativemoduleplugin.cpp | 12 +++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/declarative/qml/qdeclarativeimport.cpp b/src/declarative/qml/qdeclarativeimport.cpp index 87183c4..244f2ad 100644 --- a/src/declarative/qml/qdeclarativeimport.cpp +++ b/src/declarative/qml/qdeclarativeimport.cpp @@ -952,7 +952,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 +975,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/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp b/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp index 9ec0f84..8e31fd1 100644 --- a/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp +++ b/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp @@ -191,8 +191,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; -- cgit v0.12 From f4fedd8981bf89b690bc9167bf48c1cf5e5120f2 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Fri, 11 Feb 2011 13:08:55 +1000 Subject: Flickable uses the flick velocity to determine whether to retain grab Flickable keeps the mouse grab if it was recently flicked and another flick is started before it has settled. However, it is using the velocity of the flick rather than the instantaneous velocity of the view, which causes it to be grabbed unless the view has come to a complete stop. Use smoothedVelocity which is updated during the view movement. Also increase the threshold a little. Change-Id: I970318680d38103468155fa566c489c7874d1b00 Task-number: QTBUG-17383 Reviewed-by: Michael Brasser --- src/declarative/graphicsitems/qdeclarativeflickable.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/declarative/graphicsitems/qdeclarativeflickable.cpp b/src/declarative/graphicsitems/qdeclarativeflickable.cpp index 87578b4..5d5fd0b 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; -- cgit v0.12 From 48b9220a1c53ccb6726147381e2ace41927d3b0d Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Fri, 11 Feb 2011 14:54:16 +1000 Subject: Correct the "module not installed" error handling The not installed error will be issued if, after loading plugins and considering the contents of qmldir, there are no elements in the particular minor version. For example, if a plugin/qmldir provides the following types (either from C++ or as QML files specified in the qmldir file): Foo 1.1 Bar 1.3 importing versions 1.0, 1.2, or 1.4 will fail with the not installed error. Change-Id: I8566fda6918cb48936144e67a1ce75add0f160d8 Task-number: QTBUG-17324 Reviewed-by: Martin Jones --- src/declarative/qml/qdeclarativeimport.cpp | 25 ++++---- .../data/importsMixedQmlCppPlugin.2.qml | 21 +++++++ .../data/importsMixedQmlCppPlugin.qml | 13 ++++ .../data/versionNotInstalled.2.errors.txt | 1 + .../data/versionNotInstalled.2.qml | 5 ++ .../data/versionNotInstalled.errors.txt | 1 + .../data/versionNotInstalled.qml | 6 ++ .../com/nokia/AutoTestQmlMixedPluginType/Foo.qml | 5 ++ .../com/nokia/AutoTestQmlMixedPluginType/qmldir | 2 + .../com/nokia/AutoTestQmlVersionPluginType/qmldir | 1 + .../pluginMixed/plugin.cpp | 73 ++++++++++++++++++++++ .../pluginMixed/pluginMixed.pro | 9 +++ .../pluginVersion/plugin.cpp | 73 ++++++++++++++++++++++ .../pluginVersion/pluginVersion.pro | 9 +++ .../qdeclarativemoduleplugin.pro | 2 +- .../tst_qdeclarativemoduleplugin.cpp | 52 +++++++++++++++ 16 files changed, 285 insertions(+), 13 deletions(-) create mode 100644 tests/auto/declarative/qdeclarativemoduleplugin/data/importsMixedQmlCppPlugin.2.qml create mode 100644 tests/auto/declarative/qdeclarativemoduleplugin/data/importsMixedQmlCppPlugin.qml create mode 100644 tests/auto/declarative/qdeclarativemoduleplugin/data/versionNotInstalled.2.errors.txt create mode 100644 tests/auto/declarative/qdeclarativemoduleplugin/data/versionNotInstalled.2.qml create mode 100644 tests/auto/declarative/qdeclarativemoduleplugin/data/versionNotInstalled.errors.txt create mode 100644 tests/auto/declarative/qdeclarativemoduleplugin/data/versionNotInstalled.qml create mode 100644 tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestQmlMixedPluginType/Foo.qml create mode 100644 tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestQmlMixedPluginType/qmldir create mode 100644 tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestQmlVersionPluginType/qmldir create mode 100644 tests/auto/declarative/qdeclarativemoduleplugin/pluginMixed/plugin.cpp create mode 100644 tests/auto/declarative/qdeclarativemoduleplugin/pluginMixed/pluginMixed.pro create mode 100644 tests/auto/declarative/qdeclarativemoduleplugin/pluginVersion/plugin.cpp create mode 100644 tests/auto/declarative/qdeclarativemoduleplugin/pluginVersion/pluginVersion.pro diff --git a/src/declarative/qml/qdeclarativeimport.cpp b/src/declarative/qml/qdeclarativeimport.cpp index 244f2ad..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::ConstIterator it = qmldircomponents.begin(); int lowest_maj = INT_MAX; int lowest_min = INT_MAX; 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 +#include +#include +#include + +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(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 +#include +#include +#include + +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(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 8e31fd1..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 @@ -256,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("file"); + QTest::addColumn("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" -- cgit v0.12 From 2855782a45b08aedbed960125514fdd9663ff1c8 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Thu, 10 Feb 2011 14:37:15 +0100 Subject: Rename 'plugins\qmldebugging' (work around qmake issues) On Windows, qmake places the tcpserver.dll in a 'plugins\qmlreleaseging' folder, which broke remote debugging of QtDeclarative completely. New name 'qmltooling' while being not so specific, avoids the use of 'debug' in the folder name. Task-number: QTBUG-17360 Reviewed-by: Martin Jones --- .../debugger/qdeclarativedebugserver.cpp | 2 +- src/plugins/plugins.pro | 2 +- src/plugins/qmldebugging/qmldebugging.pro | 4 - .../tcpserver/qtcpserverconnection.cpp | 173 --------------------- .../qmldebugging/tcpserver/qtcpserverconnection.h | 84 ---------- src/plugins/qmldebugging/tcpserver/tcpserver.pro | 18 --- src/plugins/qmltooling/qmltooling.pro | 4 + .../qmltooling/tcpserver/qtcpserverconnection.cpp | 173 +++++++++++++++++++++ .../qmltooling/tcpserver/qtcpserverconnection.h | 84 ++++++++++ src/plugins/qmltooling/tcpserver/tcpserver.pro | 18 +++ tools/qml/qml.pro | 4 +- 11 files changed, 283 insertions(+), 283 deletions(-) delete mode 100644 src/plugins/qmldebugging/qmldebugging.pro delete mode 100644 src/plugins/qmldebugging/tcpserver/qtcpserverconnection.cpp delete mode 100644 src/plugins/qmldebugging/tcpserver/qtcpserverconnection.h delete mode 100644 src/plugins/qmldebugging/tcpserver/tcpserver.pro create mode 100644 src/plugins/qmltooling/qmltooling.pro create mode 100644 src/plugins/qmltooling/tcpserver/qtcpserverconnection.cpp create mode 100644 src/plugins/qmltooling/tcpserver/qtcpserverconnection.h create mode 100644 src/plugins/qmltooling/tcpserver/tcpserver.pro 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/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/qmldebugging/qmldebugging.pro deleted file mode 100644 index 01cf1a9..0000000 --- a/src/plugins/qmldebugging/qmldebugging.pro +++ /dev/null @@ -1,4 +0,0 @@ -TEMPLATE = subdirs - -SUBDIRS = tcpserver - diff --git a/src/plugins/qmldebugging/tcpserver/qtcpserverconnection.cpp b/src/plugins/qmldebugging/tcpserver/qtcpserverconnection.cpp deleted file mode 100644 index 69c1ef5..0000000 --- a/src/plugins/qmldebugging/tcpserver/qtcpserverconnection.cpp +++ /dev/null @@ -1,173 +0,0 @@ -/**************************************************************************** -** -** 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 QtDeclarative module 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 "qtcpserverconnection.h" - -#include -#include - -#include -#include - -QT_BEGIN_NAMESPACE - -class QTcpServerConnectionPrivate { -public: - QTcpServerConnectionPrivate(); - - int port; - QTcpSocket *socket; - QPacketProtocol *protocol; - QTcpServer *tcpServer; - - QDeclarativeDebugServer *debugServer; -}; - -QTcpServerConnectionPrivate::QTcpServerConnectionPrivate() : - port(0), - socket(0), - protocol(0), - tcpServer(0), - debugServer(0) -{ -} - -QTcpServerConnection::QTcpServerConnection() : - d_ptr(new QTcpServerConnectionPrivate) -{ - -} - -QTcpServerConnection::~QTcpServerConnection() -{ - delete d_ptr; -} - -void QTcpServerConnection::setServer(QDeclarativeDebugServer *server) -{ - Q_D(QTcpServerConnection); - d->debugServer = server; -} - -bool QTcpServerConnection::isConnected() const -{ - Q_D(const QTcpServerConnection); - return d->socket && d->socket->state() == QTcpSocket::ConnectedState; -} - -void QTcpServerConnection::send(const QByteArray &message) -{ - Q_D(QTcpServerConnection); - - if (!isConnected()) - return; - - QPacket pack; - pack.writeRawData(message.data(), message.length()); - - d->protocol->send(pack); - d->socket->flush(); -} - -void QTcpServerConnection::disconnect() -{ - Q_D(QTcpServerConnection); - - delete d->protocol; - d->protocol = 0; - delete d->socket; - d->socket = 0; -} - -void QTcpServerConnection::setPort(int port, bool block) -{ - Q_D(QTcpServerConnection); - d->port = port; - - listen(); - if (block) - d->tcpServer->waitForNewConnection(-1); -} - -void QTcpServerConnection::listen() -{ - Q_D(QTcpServerConnection); - - d->tcpServer = new QTcpServer(this); - QObject::connect(d->tcpServer, SIGNAL(newConnection()), this, SLOT(newConnection())); - if (d->tcpServer->listen(QHostAddress::Any, d->port)) - qWarning("QDeclarativeDebugServer: Waiting for connection on port %d...", d->port); - else - qWarning("QDeclarativeDebugServer: Unable to listen on port %d", d->port); -} - - -void QTcpServerConnection::readyRead() -{ - Q_D(QTcpServerConnection); - QPacket packet = d->protocol->read(); - - QByteArray content = packet.data(); - d->debugServer->receiveMessage(content); -} - -void QTcpServerConnection::newConnection() -{ - Q_D(QTcpServerConnection); - - if (d->socket) { - qWarning("QDeclarativeDebugServer: Another client is already connected"); - QTcpSocket *faultyConnection = d->tcpServer->nextPendingConnection(); - delete faultyConnection; - return; - } - - d->socket = d->tcpServer->nextPendingConnection(); - d->socket->setParent(this); - d->protocol = new QPacketProtocol(d->socket, this); - QObject::connect(d->protocol, SIGNAL(readyRead()), this, SLOT(readyRead())); -} - - -Q_EXPORT_PLUGIN2(tcpserver, QTcpServerConnection) - -QT_END_NAMESPACE - diff --git a/src/plugins/qmldebugging/tcpserver/qtcpserverconnection.h b/src/plugins/qmldebugging/tcpserver/qtcpserverconnection.h deleted file mode 100644 index a6e17e6..0000000 --- a/src/plugins/qmldebugging/tcpserver/qtcpserverconnection.h +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** 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 QtDeclarative module 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$ -** -****************************************************************************/ - -#ifndef QTCPSERVERCONNECTION_H -#define QTCPSERVERCONNECTION_H - -#include -#include - -QT_BEGIN_NAMESPACE - -class QDeclarativeDebugServer; -class QTcpServerConnectionPrivate; -class QTcpServerConnection : public QObject, public QDeclarativeDebugServerConnection -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QTcpServerConnection) - Q_DISABLE_COPY(QTcpServerConnection) - Q_INTERFACES(QDeclarativeDebugServerConnection) - - -public: - QTcpServerConnection(); - ~QTcpServerConnection(); - - void setServer(QDeclarativeDebugServer *server); - void setPort(int port, bool bock); - - bool isConnected() const; - void send(const QByteArray &message); - void disconnect(); - - void listen(); - void waitForConnection(); - -private Q_SLOTS: - void readyRead(); - void newConnection(); - -private: - QTcpServerConnectionPrivate *d_ptr; -}; - -QT_END_NAMESPACE - -#endif // QTCPSERVERCONNECTION_H diff --git a/src/plugins/qmldebugging/tcpserver/tcpserver.pro b/src/plugins/qmldebugging/tcpserver/tcpserver.pro deleted file mode 100644 index e90fb34..0000000 --- a/src/plugins/qmldebugging/tcpserver/tcpserver.pro +++ /dev/null @@ -1,18 +0,0 @@ -TARGET = tcpserver -QT += declarative network - -include(../../qpluginbase.pri) - -QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/qmldebugging -QTDIR_build:REQUIRES += "contains(QT_CONFIG, declarative)" - -SOURCES += \ - qtcpserverconnection.cpp - -HEADERS += \ - qtcpserverconnection.h - -target.path += $$[QT_INSTALL_PLUGINS]/qmldebugging -INSTALLS += target - -symbian:TARGET.UID3=0x20031E90 \ No newline at end of file diff --git a/src/plugins/qmltooling/qmltooling.pro b/src/plugins/qmltooling/qmltooling.pro new file mode 100644 index 0000000..01cf1a9 --- /dev/null +++ b/src/plugins/qmltooling/qmltooling.pro @@ -0,0 +1,4 @@ +TEMPLATE = subdirs + +SUBDIRS = tcpserver + diff --git a/src/plugins/qmltooling/tcpserver/qtcpserverconnection.cpp b/src/plugins/qmltooling/tcpserver/qtcpserverconnection.cpp new file mode 100644 index 0000000..69c1ef5 --- /dev/null +++ b/src/plugins/qmltooling/tcpserver/qtcpserverconnection.cpp @@ -0,0 +1,173 @@ +/**************************************************************************** +** +** 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 QtDeclarative module 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 "qtcpserverconnection.h" + +#include +#include + +#include +#include + +QT_BEGIN_NAMESPACE + +class QTcpServerConnectionPrivate { +public: + QTcpServerConnectionPrivate(); + + int port; + QTcpSocket *socket; + QPacketProtocol *protocol; + QTcpServer *tcpServer; + + QDeclarativeDebugServer *debugServer; +}; + +QTcpServerConnectionPrivate::QTcpServerConnectionPrivate() : + port(0), + socket(0), + protocol(0), + tcpServer(0), + debugServer(0) +{ +} + +QTcpServerConnection::QTcpServerConnection() : + d_ptr(new QTcpServerConnectionPrivate) +{ + +} + +QTcpServerConnection::~QTcpServerConnection() +{ + delete d_ptr; +} + +void QTcpServerConnection::setServer(QDeclarativeDebugServer *server) +{ + Q_D(QTcpServerConnection); + d->debugServer = server; +} + +bool QTcpServerConnection::isConnected() const +{ + Q_D(const QTcpServerConnection); + return d->socket && d->socket->state() == QTcpSocket::ConnectedState; +} + +void QTcpServerConnection::send(const QByteArray &message) +{ + Q_D(QTcpServerConnection); + + if (!isConnected()) + return; + + QPacket pack; + pack.writeRawData(message.data(), message.length()); + + d->protocol->send(pack); + d->socket->flush(); +} + +void QTcpServerConnection::disconnect() +{ + Q_D(QTcpServerConnection); + + delete d->protocol; + d->protocol = 0; + delete d->socket; + d->socket = 0; +} + +void QTcpServerConnection::setPort(int port, bool block) +{ + Q_D(QTcpServerConnection); + d->port = port; + + listen(); + if (block) + d->tcpServer->waitForNewConnection(-1); +} + +void QTcpServerConnection::listen() +{ + Q_D(QTcpServerConnection); + + d->tcpServer = new QTcpServer(this); + QObject::connect(d->tcpServer, SIGNAL(newConnection()), this, SLOT(newConnection())); + if (d->tcpServer->listen(QHostAddress::Any, d->port)) + qWarning("QDeclarativeDebugServer: Waiting for connection on port %d...", d->port); + else + qWarning("QDeclarativeDebugServer: Unable to listen on port %d", d->port); +} + + +void QTcpServerConnection::readyRead() +{ + Q_D(QTcpServerConnection); + QPacket packet = d->protocol->read(); + + QByteArray content = packet.data(); + d->debugServer->receiveMessage(content); +} + +void QTcpServerConnection::newConnection() +{ + Q_D(QTcpServerConnection); + + if (d->socket) { + qWarning("QDeclarativeDebugServer: Another client is already connected"); + QTcpSocket *faultyConnection = d->tcpServer->nextPendingConnection(); + delete faultyConnection; + return; + } + + d->socket = d->tcpServer->nextPendingConnection(); + d->socket->setParent(this); + d->protocol = new QPacketProtocol(d->socket, this); + QObject::connect(d->protocol, SIGNAL(readyRead()), this, SLOT(readyRead())); +} + + +Q_EXPORT_PLUGIN2(tcpserver, QTcpServerConnection) + +QT_END_NAMESPACE + diff --git a/src/plugins/qmltooling/tcpserver/qtcpserverconnection.h b/src/plugins/qmltooling/tcpserver/qtcpserverconnection.h new file mode 100644 index 0000000..a6e17e6 --- /dev/null +++ b/src/plugins/qmltooling/tcpserver/qtcpserverconnection.h @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** 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 QtDeclarative module 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$ +** +****************************************************************************/ + +#ifndef QTCPSERVERCONNECTION_H +#define QTCPSERVERCONNECTION_H + +#include +#include + +QT_BEGIN_NAMESPACE + +class QDeclarativeDebugServer; +class QTcpServerConnectionPrivate; +class QTcpServerConnection : public QObject, public QDeclarativeDebugServerConnection +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QTcpServerConnection) + Q_DISABLE_COPY(QTcpServerConnection) + Q_INTERFACES(QDeclarativeDebugServerConnection) + + +public: + QTcpServerConnection(); + ~QTcpServerConnection(); + + void setServer(QDeclarativeDebugServer *server); + void setPort(int port, bool bock); + + bool isConnected() const; + void send(const QByteArray &message); + void disconnect(); + + void listen(); + void waitForConnection(); + +private Q_SLOTS: + void readyRead(); + void newConnection(); + +private: + QTcpServerConnectionPrivate *d_ptr; +}; + +QT_END_NAMESPACE + +#endif // QTCPSERVERCONNECTION_H diff --git a/src/plugins/qmltooling/tcpserver/tcpserver.pro b/src/plugins/qmltooling/tcpserver/tcpserver.pro new file mode 100644 index 0000000..f4f2666 --- /dev/null +++ b/src/plugins/qmltooling/tcpserver/tcpserver.pro @@ -0,0 +1,18 @@ +TARGET = tcpserver +QT += declarative network + +include(../../qpluginbase.pri) + +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/qmltooling +QTDIR_build:REQUIRES += "contains(QT_CONFIG, declarative)" + +SOURCES += \ + qtcpserverconnection.cpp + +HEADERS += \ + qtcpserverconnection.h + +target.path += $$[QT_INSTALL_PLUGINS]/qmltooling +INSTALLS += target + +symbian:TARGET.UID3=0x20031E90 \ No newline at end of file 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 { -- cgit v0.12 From 1c05257ed6de27c7d9dcc90f23f868035eb738e5 Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Fri, 11 Feb 2011 13:51:48 +0100 Subject: Build Qt with GCCE 4.4.1, Symbian^3 PDK on Linux and Mac OS X. Remove the define of _STLP_NO_EXCEPTION_HEADER after OpenC team's suggestion. Remove the hardcoded include path for openc, it is already provided by mkspecs/features/symbian/platform_paths.prf. RevBy: Miikka Heikkinen Backport from 7c12d841fb2e2963b506c1ffc857cdd88bf78f6c in master. --- mkspecs/symbian/linux-gcce/qmake.conf | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/mkspecs/symbian/linux-gcce/qmake.conf b/mkspecs/symbian/linux-gcce/qmake.conf index 4c346da..62cc9ae 100644 --- a/mkspecs/symbian/linux-gcce/qmake.conf +++ b/mkspecs/symbian/linux-gcce/qmake.conf @@ -50,8 +50,7 @@ QMAKE_LFLAGS_NOUNDEF = QMAKE_LFLAGS_RPATH = --rpath= DEFINES += __GCCE__ \ - UNICODE \ - _STLP_NO_EXCEPTION_HEADER + UNICODE QMAKE_LFLAGS_APP += --entry=_E32Startup -u _E32Startup QMAKE_LFLAGS_SHLIB += --default-symver --entry=_E32Dll -u _E32Dll @@ -89,7 +88,5 @@ INCLUDEPATH = ${EPOCROOT}/epoc32/include/ \ $${EPOCROOT}/epoc32/include/variant \ $${EPOCROOT}/epoc32/include/stdapis \ $${EPOCROOT}/epoc32/include/gcce \ - ${EPOCROOT}/epoc32/include/stdapis/sys \ - ${EPOCROOT}/epoc32/include/stdapis/stlport \ $$INCLUDEPATH -- cgit v0.12 From 46de2eb6aacc862b60cb01cc6a0c5e1775265099 Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Fri, 11 Feb 2011 13:53:34 +0100 Subject: Apply the gcce link rules for LIBS_PRIVATE too. It's needed by building QtOpenGL of Qt for Symbian on Linux and Mac with gcce at least. RevBy: axis --- mkspecs/features/symbian/symbian_building.prf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mkspecs/features/symbian/symbian_building.prf b/mkspecs/features/symbian/symbian_building.prf index f3b6c25..0d2e053 100644 --- a/mkspecs/features/symbian/symbian_building.prf +++ b/mkspecs/features/symbian/symbian_building.prf @@ -51,7 +51,7 @@ defineReplace(processSymbianLibrary) { } # This part turn "-llibc" into "libc.dso", and moves -L entries to QMAKE_LIBDIR. -libsToProcess = LIBS QMAKE_LIBS +libsToProcess = LIBS LIBS_PRIVATE QMAKE_LIBS for(libToProcess, libsToProcess) { qt_libraries = $$split($$libToProcess, " ") eval($$libToProcess =) @@ -90,8 +90,8 @@ count(splitVersion, 0) { } else { count(splitVersion, 3) { hexVersion = $$system("sh -c 'printf %02x $$member(splitVersion, 0)'") - hexPart2 = $$system("sh -c 'printf %02x $$member(splitVersion, 1)'")" - hexPart2 = $$hexPart2$$system("sh -c 'printf %02x $$member(splitVersion, 2)'")" + hexPart2 = $$system("sh -c 'printf %02x $$member(splitVersion, 1)'") + hexPart2 = $$hexPart2$$system("sh -c 'printf %02x $$member(splitVersion, 2)'") decVersion = $$system("sh -c 'printf %1d 0x$$hexVersion'"). hexVersion = $$hexVersion$$hexPart2 decVersion = $$decVersion$$system("sh -c 'printf %d 0x$$hexPart2'") -- cgit v0.12 From f7e75244ab62b1fe0d1d73b84a6089d6b2a81d1a Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 11 Feb 2011 14:27:39 +0100 Subject: Designer: Slots of main container not visible in signal/slot editor. Fix a regression introduced by dd7873cd7e02e42b384709f33a34f69bc06fb25d of QTBUG-17179. Reviewed-by: Kai Koehne Task-number: QTBUG-17358 --- .../designer/src/components/signalsloteditor/signalslot_utils.cpp | 7 ++++++- .../src/components/signalsloteditor/signalsloteditorwindow.cpp | 8 ++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/tools/designer/src/components/signalsloteditor/signalslot_utils.cpp b/tools/designer/src/components/signalsloteditor/signalslot_utils.cpp index d0af770..9f72816 100644 --- a/tools/designer/src/components/signalsloteditor/signalslot_utils.cpp +++ b/tools/designer/src/components/signalsloteditor/signalslot_utils.cpp @@ -244,7 +244,12 @@ namespace qdesigner_internal { ClassesMemberFunctions reverseClassesMemberFunctions(const QString &obj_name, MemberType member_type, const QString &peer, QDesignerFormWindowInterface *form) { - QObject *object = qFindChild(form->mainContainer(), obj_name); + QObject *object = 0; + if (obj_name == form->mainContainer()->objectName()) { + object = form->mainContainer(); + } else { + object = qFindChild(form->mainContainer(), obj_name); + } if (!object) return ClassesMemberFunctions(); QDesignerFormEditorInterface *core = form->core(); diff --git a/tools/designer/src/components/signalsloteditor/signalsloteditorwindow.cpp b/tools/designer/src/components/signalsloteditor/signalsloteditorwindow.cpp index 831649f..6690948 100644 --- a/tools/designer/src/components/signalsloteditor/signalsloteditorwindow.cpp +++ b/tools/designer/src/components/signalsloteditor/signalsloteditorwindow.cpp @@ -658,8 +658,12 @@ QWidget *ConnectionDelegate::createEditor(QWidget *parent, const qdesigner_internal::ClassesMemberFunctions class_list = qdesigner_internal::reverseClassesMemberFunctions(obj_name, type, peer, m_form); - QObject *object = qFindChild(m_form->mainContainer(), obj_name); - + QObject *object = 0; + if (obj_name == m_form->mainContainer()->objectName()) { + object = m_form->mainContainer(); + } else { + object = qFindChild(m_form->mainContainer(), obj_name); + } inline_editor->addText(type == qdesigner_internal::SignalMember ? tr("") : tr("")); foreach (const qdesigner_internal::ClassMemberFunctions &class_info, class_list) { if (class_info.m_className.isEmpty() || class_info.m_memberList.isEmpty()) -- cgit v0.12 From 3bc6f8d8dd630cd0298e27fc4b7430d2bf73a232 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Mon, 14 Feb 2011 14:25:15 +1000 Subject: Don't leak ScopeChainNode's Create a sub-scope of the global scope chain, rather than a completely new scope chain. Leaks are difficult to autotest, but an autotest for QScriptDeclarativeClass::pushCleanContext() was added to ensure its behavior doesn't regress. To reproduce the leak (prior to this change) use: while (true) { QScriptDeclarativeClass::pushCleanContext(&engine); engine.popContext(); } Change-Id: I41ac61ea1664da569eb329c8276f2a0bb6d2f1f7 Task-number: QTBUG-17166 Reviewed-by: Martin Jones --- src/script/api/qscriptengine.cpp | 4 +-- .../tst_qdeclarativeecmascript.cpp | 40 ++++++++++++++++++++++ 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp index 54039c0..e58c43b 100644 --- a/src/script/api/qscriptengine.cpp +++ b/src/script/api/qscriptengine.cpp @@ -2761,9 +2761,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 #include #include +#include #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" -- cgit v0.12 From 984bc6626c4f290572ac721fd10edda99691306f Mon Sep 17 00:00:00 2001 From: axis Date: Mon, 14 Feb 2011 10:12:21 +0100 Subject: Worked around a SC issue in S60 3.x vs 5.0 versions. Task: QTBUG-16578 RevBy: Gareth Stockwell --- src/gui/kernel/qwidget_s60.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index 1551162..af9ae47 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -54,7 +54,6 @@ #ifdef Q_WS_S60 #include -#include #include #endif @@ -64,6 +63,19 @@ // CCoeControl objects until after the CONE event handler has finished running. Q_DECLARE_METATYPE(WId) +// Workaround for the fact that S60 SDKs 3.x do not contain the akntoolbar.h +// header, even though the documentation says that it should be there, and indeed +// it is present in the library. +class CAknToolbar : public CAknControl, + public MCoeControlObserver, + public MCoeControlBackground, + public MEikCommandObserver, + public MAknFadedComponent +{ +public: + IMPORT_C void SetToolbarVisibility(const TBool visible); +}; + QT_BEGIN_NAMESPACE extern bool qt_nograb(); -- cgit v0.12 From 0bf70c35bd51be4435c95f28dab96bf9f00b49db Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 14 Feb 2011 10:57:26 +0100 Subject: QStyleSheetStyle: dont crash in PE_WIDGET when widget is null Reviewed-by: Gabriel Task-number: QTBUG-15910 --- src/gui/styles/qstylesheetstyle.cpp | 2 +- tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp index 2b3dffc..a4e7c38 100644 --- a/src/gui/styles/qstylesheetstyle.cpp +++ b/src/gui/styles/qstylesheetstyle.cpp @@ -4248,7 +4248,7 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op return; case PE_Widget: - if (!rule.hasDrawable()) { + if (w && !rule.hasDrawable()) { QWidget *container = containerWidget(w); if (autoFillDisabledWidgets->contains(container) && (container == w || !renderRule(container, opt).hasBackground())) { diff --git a/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp b/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp index f3e21a0..c386ffb 100644 --- a/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp +++ b/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp @@ -100,6 +100,7 @@ private slots: void task188195_baseBackground(); void task232085_spinBoxLineEditBg(); void changeStyleInChangeEvent(); + void QTBUG15910_crashNullWidget(); //at the end because it mess with the style. void widgetStyle(); @@ -1626,6 +1627,24 @@ void tst_QStyleSheetStyle::changeStyleInChangeEvent() wid.ensurePolished(); } +void tst_QStyleSheetStyle::QTBUG15910_crashNullWidget() +{ + struct : QWidget { + virtual void paintEvent(QPaintEvent* ) { + QStyleOption opt; + opt.init(this); + QPainter p(this); + style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, 0); + style()->drawPrimitive(QStyle::PE_Frame, &opt, &p, 0); + style()->drawControl(QStyle::CE_PushButton, &opt, &p, 0); + } + } w; + w.setStyleSheet("* { background-color: white; color:black; border 3px solid yellow }"); + w.show(); + QTest::qWaitForWindowShown(&w); +} + + QTEST_MAIN(tst_QStyleSheetStyle) #include "tst_qstylesheetstyle.moc" -- cgit v0.12 From 220efa578b7d032257c7fa95aaf1295330fd474e Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Mon, 14 Feb 2011 13:29:14 +0100 Subject: Keep sending posted events after commit 7196045b78b33cf135683d5c0b4e164f95231791 This commit put in place a timer based mechanism to ensure that posted events continue to be sent. As pointed out in commit eb1015c7bbf135af3656110a4d112377c1209db8, GetQueueStatus() can indicate that there are messages in the queue but our hook never actually receives them, hence the timer solution. However, having the message type and hwnd "guards" in the conditional for starting a timer would cause us to lose events in some situations, due to the fact that QEventDispatcherWin32::processEvents() will only allow one WM_QT_SENDPOSTEDEVENTS message per call (multiple messages will be compressed into a single one). When racing with other threads, it would be possible to end up blocking one thread that has pending posted events unintentionally. This fix removes the guards and makes sure that we start the keep alive timer when it's really needed, and only stops it when we really know that there is nothing left in the Windows message queue. Task-number: QTBUG-17014 Reviewed-by: joao Reviewed-by: Marius Storm-Olsen --- src/corelib/kernel/qeventdispatcher_win.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp index bba563a..6d90a51 100644 --- a/src/corelib/kernel/qeventdispatcher_win.cpp +++ b/src/corelib/kernel/qeventdispatcher_win.cpp @@ -530,10 +530,7 @@ LRESULT QT_WIN_CALLBACK qt_GetMessageHook(int code, WPARAM wp, LPARAM lp) PostMessage(d->internalHwnd, WM_QT_SENDPOSTEDEVENTS, 0, 0); } } else if (d->sendPostedEventsWindowsTimerId == 0 - && localSerialNumber != d->lastSerialNumber - // if this message IS the one that triggers sendPostedEvents(), no need to post it again - && (msg->hwnd != d->internalHwnd - || msg->message != WM_QT_SENDPOSTEDEVENTS)) { + && localSerialNumber != d->lastSerialNumber) { // start a special timer to continue delivering posted events while // there are still input and timer messages in the message queue d->sendPostedEventsWindowsTimerId = SetTimer(d->internalHwnd, -- cgit v0.12 From 04ddaa986504e3842920770927cb7247e5e0fb78 Mon Sep 17 00:00:00 2001 From: Jani Hautakangas Date: Mon, 14 Feb 2011 23:47:53 +0200 Subject: Fix for ARMV6 drawhelper blending Asm code used wrong source register when doing constant alpha blending. Task-number: QTBUG-16008 Reviewed-by: TRUSTME --- src/gui/painting/qdrawhelper_arm_simd.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/painting/qdrawhelper_arm_simd.cpp b/src/gui/painting/qdrawhelper_arm_simd.cpp index 806df29..af9854c 100644 --- a/src/gui/painting/qdrawhelper_arm_simd.cpp +++ b/src/gui/painting/qdrawhelper_arm_simd.cpp @@ -201,8 +201,8 @@ argb32constalpha_next_pixel uxtb16 r10, r9 uxtb16 r6, r9, ror #8 - // Negate r11 and extract src alpha - mvn r9, r11 // bitwise not + // Negate r8 and extract src alpha + mvn r9, r8 // bitwise not uxtb r9, r9, ror #24 mla r10, r9, r10, r14 -- cgit v0.12 From 5f9f98ec047024fadbfdea334fbea7c357179032 Mon Sep 17 00:00:00 2001 From: Andrew den Exter Date: Fri, 11 Feb 2011 14:30:21 +1000 Subject: Fix inheritance of widget input contexts. If a parent widget has an input context assigned return that from QWidget::inputContext() before returning QApplication::inputContext(). Change-Id: I4982a91ace9b7485534f1c31fa4e2d549482640e Task-number: QTBUG-17390 Reviewed-by: axis --- src/gui/kernel/qwidget.cpp | 21 +++++++++++++---- src/gui/kernel/qwidget_p.h | 1 + tests/auto/qinputcontext/tst_qinputcontext.cpp | 32 ++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 4 deletions(-) diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index e542a59..7065e85 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -393,11 +393,24 @@ void QWidgetPrivate::scrollChildren(int dx, int dy) } } +QInputContext *QWidgetPrivate::assignedInputContext() const +{ +#ifndef QT_NO_IM + const QWidget *widget = q_func(); + while (widget) { + if (QInputContext *qic = widget->d_func()->ic) + return qic; + widget = widget->parentWidget(); + } +#endif + return 0; +} + QInputContext *QWidgetPrivate::inputContext() const { #ifndef QT_NO_IM - if (ic) - return ic; + if (QInputContext *qic = assignedInputContext()) + return qic; return qApp->inputContext(); #else return 0; @@ -10721,7 +10734,7 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on) case Qt::WA_InputMethodEnabled: { #ifndef QT_NO_IM QWidget *focusWidget = d->effectiveFocusWidget(); - QInputContext *ic = focusWidget->d_func()->ic; + QInputContext *ic = focusWidget->d_func()->assignedInputContext(); if (!ic && (!on || hasFocus())) ic = focusWidget->d_func()->inputContext(); if (ic) { @@ -11208,7 +11221,7 @@ void QWidget::updateMicroFocus() #if !defined(QT_NO_IM) && (defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN)) Q_D(QWidget); // and optimization to update input context only it has already been created. - if (d->ic || qApp->d_func()->inputContext) { + if (d->assignedInputContext() || qApp->d_func()->inputContext) { QInputContext *ic = inputContext(); if (ic) ic->update(); diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h index 3759dd1..9f6ba6f 100644 --- a/src/gui/kernel/qwidget_p.h +++ b/src/gui/kernel/qwidget_p.h @@ -559,6 +559,7 @@ public: // sub-classes that their internals are about to be released. virtual void aboutToDestroy() {} + QInputContext *assignedInputContext() const; QInputContext *inputContext() const; inline QWidget *effectiveFocusWidget() { QWidget *w = q_func(); diff --git a/tests/auto/qinputcontext/tst_qinputcontext.cpp b/tests/auto/qinputcontext/tst_qinputcontext.cpp index 800f9de..6a047f2 100644 --- a/tests/auto/qinputcontext/tst_qinputcontext.cpp +++ b/tests/auto/qinputcontext/tst_qinputcontext.cpp @@ -88,6 +88,7 @@ private slots: void closeSoftwareInputPanel(); void selections(); void focusProxy(); + void contextInheritance(); void symbianTestCoeFepInputContext_data(); void symbianTestCoeFepInputContext(); void symbianTestCoeFepAutoCommit_data(); @@ -473,6 +474,37 @@ void tst_QInputContext::focusProxy() QCOMPARE(gic->focusWidget(), &proxy); } +void tst_QInputContext::contextInheritance() +{ + QWidget parent; + QWidget child(&parent); + + parent.setAttribute(Qt::WA_InputMethodEnabled, true); + child.setAttribute(Qt::WA_InputMethodEnabled, true); + + QCOMPARE(parent.inputContext(), qApp->inputContext()); + QCOMPARE(child.inputContext(), qApp->inputContext()); + + QInputContext *qic = new QFilterInputContext; + parent.setInputContext(qic); + QCOMPARE(parent.inputContext(), qic); + QCOMPARE(child.inputContext(), qic); + + parent.setAttribute(Qt::WA_InputMethodEnabled, false); + QVERIFY(!parent.inputContext()); + QCOMPARE(child.inputContext(), qic); + parent.setAttribute(Qt::WA_InputMethodEnabled, true); + + parent.setInputContext(0); + QCOMPARE(parent.inputContext(), qApp->inputContext()); + QCOMPARE(child.inputContext(), qApp->inputContext()); + + qic = new QFilterInputContext; + qApp->setInputContext(qic); + QCOMPARE(parent.inputContext(), qic); + QCOMPARE(child.inputContext(), qic); +} + #ifdef QT_WEBKIT_LIB class AutoWebView : public QWebView { -- cgit v0.12 From fbd07cf7b756b903ab888785eb520cdbf64f38d4 Mon Sep 17 00:00:00 2001 From: Andrew den Exter Date: Tue, 15 Feb 2011 16:05:35 +1000 Subject: Document the TextInput accepted() signal. Change-Id: I30a36ba2724c9641e9cfe5ceafa651728907ef63 --- src/declarative/graphicsitems/qdeclarativetextinput.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp index dce7346..ddfa3aa 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp @@ -776,6 +776,15 @@ bool QDeclarativeTextInput::hasAcceptableInput() const } /*! + \qmlsignal TextInput::accepted() + + This signal is emitted when the Return or Enter key is pressed. + Note that if there is a \l validator or \l inputMask set on the text + input, the accepted signal will only be emitted if the input + is in an acceptable state. +*/ + +/*! \qmlproperty enumeration TextInput::echoMode Specifies how the text should be displayed in the TextInput. -- cgit v0.12 From 3997977cdb712042c540b143f2ce2f5376e9d1e0 Mon Sep 17 00:00:00 2001 From: Andrew den Exter Date: Tue, 15 Feb 2011 16:14:29 +1000 Subject: Use QML notation for documenting TextInput::accepted() signal. Use the name onAccepted() and refer to it as a handler rather than a signal. Change-Id: Ibd4144aa809e6d9db136187a07e9a660afa5df1b --- src/declarative/graphicsitems/qdeclarativetextinput.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp index ddfa3aa..88f36b4 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp @@ -776,12 +776,12 @@ bool QDeclarativeTextInput::hasAcceptableInput() const } /*! - \qmlsignal TextInput::accepted() + \qmlsignal TextInput::onAccepted() - This signal is emitted when the Return or Enter key is pressed. + This handler is called when the Return or Enter key is pressed. Note that if there is a \l validator or \l inputMask set on the text - input, the accepted signal will only be emitted if the input - is in an acceptable state. + input, the handler will only be emitted if the input is in an acceptable + state. */ /*! -- cgit v0.12 From 0a84c39a92c4d4d7f2a5e19e949116df24219aa1 Mon Sep 17 00:00:00 2001 From: Jani Hautakangas Date: Thu, 10 Feb 2011 22:28:12 +0200 Subject: Fix for clipping failure in OpenVG paint engine. OpenVG implementation for Broadcom chip has limited scissor rect count to 32. Because of that Qt OpenVG paint engine fails to clip correctly if clip rect count exceeds 32. This patch makes Qt OpenVG paint engine to use mask instead of scissors in such cases. Task-number: QTBUG-16932 Reviewed-by: Jason Barron --- src/openvg/qpaintengine_vg.cpp | 35 +++++++++++++++++++++++++++++++++-- src/openvg/qwindowsurface_vgegl.cpp | 3 --- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/src/openvg/qpaintengine_vg.cpp b/src/openvg/qpaintengine_vg.cpp index a15f0c3..22cbbf5 100644 --- a/src/openvg/qpaintengine_vg.cpp +++ b/src/openvg/qpaintengine_vg.cpp @@ -2201,6 +2201,12 @@ void QVGPaintEngine::updateScissor() #if defined(QVG_SCISSOR_CLIP) // Using the scissor to do clipping, so combine the systemClip // with the current painting clipRegion. + + if (d->maskValid) { + vgSeti(VG_MASKING, VG_FALSE); + d->maskValid = false; + } + QVGPainterState *s = state(); if (s->clipEnabled) { if (region.isEmpty()) @@ -2250,8 +2256,33 @@ void QVGPaintEngine::updateScissor() QVector rects = region.rects(); int count = rects.count(); - if (count > d->maxScissorRects) - count = d->maxScissorRects; + if (count > d->maxScissorRects) { +#if !defined(QVG_SCISSOR_CLIP) + count = d->maxScissorRects; +#else + // Use masking + int width = paintDevice()->width(); + int height = paintDevice()->height(); + vgMask(VG_INVALID_HANDLE, VG_CLEAR_MASK, + 0, 0, width, height); + for (int i = 0; i < rects.size(); ++i) { + vgMask(VG_INVALID_HANDLE, VG_FILL_MASK, + rects[i].x(), height - rects[i].y() - rects[i].height(), + rects[i].width(), rects[i].height()); + } + + vgSeti(VG_SCISSORING, VG_FALSE); + vgSeti(VG_MASKING, VG_TRUE); + d->maskValid = true; + d->maskIsSet = false; + d->scissorMask = false; + d->scissorActive = false; + d->scissorDirty = false; + d->scissorRegion = region; + return; +#endif + } + QVarLengthArray params(count * 4); int height = paintDevice()->height(); for (int i = 0; i < count; ++i) { diff --git a/src/openvg/qwindowsurface_vgegl.cpp b/src/openvg/qwindowsurface_vgegl.cpp index c6db869..ca80886 100644 --- a/src/openvg/qwindowsurface_vgegl.cpp +++ b/src/openvg/qwindowsurface_vgegl.cpp @@ -267,10 +267,7 @@ static QEglContext *createContext(QPaintDevice *device) int redSize = configProps.value(EGL_RED_SIZE); if (redSize == EGL_DONT_CARE || redSize == 0) configProps.setPixelFormat(QImage::Format_ARGB32); // XXX -#ifndef QVG_SCISSOR_CLIP - // If we are using the mask to clip, then explicitly request a mask. configProps.setValue(EGL_ALPHA_MASK_SIZE, 1); -#endif #ifdef EGL_VG_ALPHA_FORMAT_PRE_BIT configProps.setValue(EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_VG_ALPHA_FORMAT_PRE_BIT); -- cgit v0.12 From 899094da212e5bb1c3b9bce03b6c91d60cbdd13f Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Wed, 16 Feb 2011 16:26:00 +0200 Subject: Introduce new flag for splitview support in Symbian Introduce new flag for splitview support as internal to Qt 4.7.2. The actual implementation will be delivered to Qt 4.7.3. Task-number: QTBUG-16572 Reviewed-by: Janne Koskinen --- src/corelib/global/qnamespace.h | 1 + src/corelib/global/qnamespace.qdoc | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index e492345..398f9bf 100644 --- a/src/corelib/global/qnamespace.h +++ b/src/corelib/global/qnamespace.h @@ -541,6 +541,7 @@ public: AA_DontUseNativeMenuBar = 6, AA_MacDontSwapCtrlAndMeta = 7, AA_S60DontConstructApplicationPanes = 8, + AA_S60DisablePartialScreenInputMode = 9, // Add new attributes before this line AA_AttributeCount diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index 8440542..22382cd 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -156,6 +156,13 @@ whole lifetime. This attribute must be set before QApplication is constructed. + \omitvalue AA_S60DisablePartialScreenInputMode By default in Symbian^3, + a separate editing window is opened on top of an application. This is exactly + like editing on previous versions of Symbian behave. When this attribute + is true, a virtual keyboard window is shown on top of application and it + is ensured that the focused text widget is visible. This is only supported in + Symbian^3. (internal) + \omitvalue AA_AttributeCount */ -- cgit v0.12 From 48e7ac0eee8beb9d2c597ff5fa3c913d56ffb9b0 Mon Sep 17 00:00:00 2001 From: Eckhart Koppen Date: Wed, 16 Feb 2011 17:34:00 +0200 Subject: Made Q_ASSERT meaningful again m_bytesPadding is an unsigned integer, assert would never have been triggered. Reviewed-by: TrustMe --- src/multimedia/audio/qaudiooutput_symbian_p.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/multimedia/audio/qaudiooutput_symbian_p.cpp b/src/multimedia/audio/qaudiooutput_symbian_p.cpp index ea7cd9f..5db7099 100644 --- a/src/multimedia/audio/qaudiooutput_symbian_p.cpp +++ b/src/multimedia/audio/qaudiooutput_symbian_p.cpp @@ -436,8 +436,8 @@ void QAudioOutputPrivate::writePaddingData() unsigned char *ptr = const_cast(outputBuffer.Ptr()); Mem::FillZ(ptr, paddingBytes); outputBuffer.SetLength(outputBuffer.Length() + paddingBytes); + Q_ASSERT(m_bytesPadding >= paddingBytes); m_bytesPadding -= paddingBytes; - Q_ASSERT(m_bytesPadding >= 0); if (m_pullMode && m_source->atEnd()) lastBufferFilled(); -- cgit v0.12