From 79446ca4e047e68bea68aef902a5d48478bcc9cc Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Mon, 24 May 2010 14:35:17 +1000 Subject: Don't polish QDeclarativeItems. Avoids unnecessary processing and assumptions we would not want to preserve in the future. Task-number: QTBUG-10217 Reviewed-by: Martin Jones --- src/declarative/graphicsitems/qdeclarativeitem.cpp | 8 +++++++- src/gui/graphicsview/qgraphicsscene.cpp | 14 +++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp index 9547884..2841ac3 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp @@ -2681,7 +2681,13 @@ bool QDeclarativeItem::sceneEvent(QEvent *event) } } -/*! \internal */ +/*! + \reimp + + Note that unlike QGraphicsItems, QDeclarativeItem::itemChange() is \e not called + during initial widget polishing. Items wishing to optimize start-up construction + should instead consider using componentComplete(). +*/ QVariant QDeclarativeItem::itemChange(GraphicsItemChange change, const QVariant &value) { diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index 344df30..ae0abf9 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -2545,12 +2545,16 @@ void QGraphicsScene::addItem(QGraphicsItem *item) return; } - if (d->unpolishedItems.isEmpty()) { - QMetaMethod method = metaObject()->method(d->polishItemsIndex); - method.invoke(this, Qt::QueuedConnection); + // QDeclarativeItems do not rely on initial itemChanged message, as the componentComplete + // function allows far more opportunity for delayed-construction optimization. + if (!item->d_ptr->isDeclarativeItem) { + if (d->unpolishedItems.isEmpty()) { + QMetaMethod method = metaObject()->method(d->polishItemsIndex); + method.invoke(this, Qt::QueuedConnection); + } + d->unpolishedItems.append(item); + item->d_ptr->pendingPolish = true; } - d->unpolishedItems.append(item); - item->d_ptr->pendingPolish = true; // Detach this item from its parent if the parent's scene is different // from this scene. -- cgit v0.12 From 61bd72461b2f02bdcd316b32de7749eca8692212 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Mon, 24 May 2010 15:31:15 +1000 Subject: Do not attempt to setParent of object in a different thread QNetworkAccessManager::setCookieJar used to give an error message, now it documents the behavior and avoids the warning. Task-number: QTBUG-10554 --- src/network/access/qnetworkaccessmanager.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp index 1c7661d..b7539da 100644 --- a/src/network/access/qnetworkaccessmanager.cpp +++ b/src/network/access/qnetworkaccessmanager.cpp @@ -595,8 +595,9 @@ QNetworkCookieJar *QNetworkAccessManager::cookieJar() const \note QNetworkAccessManager takes ownership of the \a cookieJar object. - QNetworkAccessManager will set the parent of the \a cookieJar - passed to itself, so that the cookie jar is deleted when this + If \a cookieJar is in the same thread as this QNetworkAccessManager, + it will set the parent of the \a cookieJar + so that the cookie jar is deleted when this object is deleted as well. If you want to share cookie jars between different QNetworkAccessManager objects, you may want to set the cookie jar's parent to 0 after calling this function. @@ -621,7 +622,8 @@ void QNetworkAccessManager::setCookieJar(QNetworkCookieJar *cookieJar) if (d->cookieJar && d->cookieJar->parent() == this) delete d->cookieJar; d->cookieJar = cookieJar; - d->cookieJar->setParent(this); + if (thread() == cookieJar->thread()) + d->cookieJar->setParent(this); } } -- cgit v0.12 From 06fbba775078def95f28139483f8645a00941fe5 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Mon, 24 May 2010 15:14:41 +1000 Subject: Fix visual tests after rename of the qml executable. --- tests/auto/declarative/qmlvisual/tst_qmlvisual.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/auto/declarative/qmlvisual/tst_qmlvisual.cpp b/tests/auto/declarative/qmlvisual/tst_qmlvisual.cpp index f105692..71dc451 100644 --- a/tests/auto/declarative/qmlvisual/tst_qmlvisual.cpp +++ b/tests/auto/declarative/qmlvisual/tst_qmlvisual.cpp @@ -81,11 +81,11 @@ QString tst_qmlvisual::viewer() QString qmlruntime; #if defined(Q_WS_MAC) - qmlruntime = QDir(binaries).absoluteFilePath("qml.app/Contents/MacOS/qml"); + qmlruntime = QDir(binaries).absoluteFilePath("QMLViewer.app/Contents/MacOS/QMLViewer"); #elif defined(Q_WS_WIN) || defined(Q_WS_S60) - qmlruntime = QDir(binaries).absoluteFilePath("qml.exe"); + qmlruntime = QDir(binaries).absoluteFilePath("qmlviewer.exe"); #else - qmlruntime = QDir(binaries).absoluteFilePath("qml"); + qmlruntime = QDir(binaries).absoluteFilePath("qmlviewer"); #endif return qmlruntime; -- cgit v0.12 From 8cc8faa6d989b8eb7cd4e78b4a51bbdc3af6ba99 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Mon, 24 May 2010 15:16:22 +1000 Subject: Get rid of 'noise' when using GL and the top-level item is an Item. Task-number: QTBUG-10911 --- tools/qml/qmlruntime.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/qml/qmlruntime.cpp b/tools/qml/qmlruntime.cpp index 8df250f..5136872 100644 --- a/tools/qml/qmlruntime.cpp +++ b/tools/qml/qmlruntime.cpp @@ -1240,7 +1240,8 @@ void QDeclarativeViewer::setUseGL(bool useGL) #endif QGLWidget *glWidget = new QGLWidget(format); - glWidget->setAutoFillBackground(false); + //### potentially faster, but causes junk to appear if top-level is Item, not Rectangle + //glWidget->setAutoFillBackground(false); canvas->setViewport(glWidget); } -- cgit v0.12 From 180e2ce2cca53f2c395e8dc9213d714c396c4555 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Mon, 24 May 2010 15:40:29 +1000 Subject: Don't crash when assigning a Behavior to a grouped property. Task-number: QTBUG-10799 Reviewed-by: Aaron Kennedy --- src/declarative/qml/qdeclarativecompiler.cpp | 17 +++++++++++++++++ src/declarative/qml/qdeclarativevmemetaobject.cpp | 2 +- .../qdeclarativebehaviors/data/groupedPropertyCrash.qml | 10 ++++++++++ .../qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp | 10 ++++++++++ 4 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 tests/auto/declarative/qdeclarativebehaviors/data/groupedPropertyCrash.qml diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp index b5bf972..d27aced 100644 --- a/src/declarative/qml/qdeclarativecompiler.cpp +++ b/src/declarative/qml/qdeclarativecompiler.cpp @@ -1089,6 +1089,23 @@ void QDeclarativeCompiler::genObjectBody(QDeclarativeParser::Object *obj) fetch.line = prop->location.start.line; output->bytecode << fetch; + if (!prop->value->metadata.isEmpty()) { + QDeclarativeInstruction meta; + meta.type = QDeclarativeInstruction::StoreMetaObject; + meta.line = 0; + meta.storeMeta.data = output->indexForByteArray(prop->value->metadata); + meta.storeMeta.aliasData = output->indexForByteArray(prop->value->synthdata); + meta.storeMeta.propertyCache = output->propertyCaches.count(); + // ### Surely the creation of this property cache could be more efficient + QDeclarativePropertyCache *propertyCache = + enginePrivate->cache(prop->value->metaObject()->superClass())->copy(); + propertyCache->append(engine, prop->value->metaObject(), QDeclarativePropertyCache::Data::NoFlags, + QDeclarativePropertyCache::Data::IsVMEFunction); + + output->propertyCaches << propertyCache; + output->bytecode << meta; + } + genObjectBody(prop->value); QDeclarativeInstruction pop; diff --git a/src/declarative/qml/qdeclarativevmemetaobject.cpp b/src/declarative/qml/qdeclarativevmemetaobject.cpp index 13e9c26..7aea7cb 100644 --- a/src/declarative/qml/qdeclarativevmemetaobject.cpp +++ b/src/declarative/qml/qdeclarativevmemetaobject.cpp @@ -381,7 +381,7 @@ QDeclarativeVMEMetaObject::QDeclarativeVMEMetaObject(QObject *obj, const QMetaObject *other, const QDeclarativeVMEMetaData *meta, QDeclarativeCompiledData *cdata) -: object(obj), compiledData(cdata), ctxt(QDeclarativeData::get(obj)->outerContext), +: object(obj), compiledData(cdata), ctxt(QDeclarativeData::get(obj, true)->outerContext), metaData(meta), data(0), methods(0), parent(0) { compiledData->addref(); diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/groupedPropertyCrash.qml b/tests/auto/declarative/qdeclarativebehaviors/data/groupedPropertyCrash.qml new file mode 100644 index 0000000..c052366 --- /dev/null +++ b/tests/auto/declarative/qdeclarativebehaviors/data/groupedPropertyCrash.qml @@ -0,0 +1,10 @@ +import Qt 4.7 + +Rectangle { + width: 200 + height: 200 + Text { + Behavior on anchors.verticalCenterOffset { NumberAnimation { duration: 300; } } + text: "Hello World" + } +} diff --git a/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp b/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp index 1dc4b53..45e5304 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp +++ b/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp @@ -72,6 +72,7 @@ private slots: void disabled(); void dontStart(); void startup(); + void groupedPropertyCrash(); }; void tst_qdeclarativebehaviors::simpleBehavior() @@ -351,6 +352,15 @@ void tst_qdeclarativebehaviors::startup() } } +//QTBUG-10799 +void tst_qdeclarativebehaviors::groupedPropertyCrash() +{ + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/groupedPropertyCrash.qml")); + QDeclarativeRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); //don't crash +} + QTEST_MAIN(tst_qdeclarativebehaviors) #include "tst_qdeclarativebehaviors.moc" -- cgit v0.12 From 56f0ab34eff5282fc0444b95fa359535a96e5c1e Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Mon, 24 May 2010 16:19:37 +1000 Subject: Doc fixes --- doc/src/declarative/examples.qdoc | 6 +++--- examples/declarative/README | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/src/declarative/examples.qdoc b/doc/src/declarative/examples.qdoc index a355f9f..6e0426c 100644 --- a/doc/src/declarative/examples.qdoc +++ b/doc/src/declarative/examples.qdoc @@ -56,17 +56,17 @@ sub-directory that show how to use various aspects of QML. In addition, the applications. These demos are intended to show integrated functionality rather than being instructive on specific elements. -To run the examples and demos, you can use Qt Creator or the included \l {Qt Declarative UI Runtime}{qml} +To run the examples and demos, you can use Qt Creator or the included \l {Qt Declarative UI Runtime}{qmlviewer} command-line application. It has some useful options, revealed by: \code - bin/qml -help + bin/qmlviewer -help \endcode For example, from your build directory, run: \code - bin/qml $QTDIR/demos/declarative/samegame/samegame.qml + bin/qmlviewer $QTDIR/demos/declarative/samegame/samegame.qml \endcode \section1 Examples diff --git a/examples/declarative/README b/examples/declarative/README index 9e0f4c4..578c245 100644 --- a/examples/declarative/README +++ b/examples/declarative/README @@ -1,5 +1,5 @@ The Qt Declarative module provides the ability to specify and implement -your UI declaratively, using the Qt Meta-Object Language(QML). This +your user interface declaratively, using the Qt Meta-Object Language (QML). This language is very expressive and human readable, and can be used by designers to actually implement their UI vision. QML UIs can integrate with C++ code in many ways, including being loaded as a part of a C++ UI @@ -9,7 +9,7 @@ The example launcher provided with Qt can be used to explore each of the examples in this directory. But most can also be viewed directly with the QML viewer utility, without requiring compilation. -Documentation for these examples can be found via the Tutorial and Examples +Documentation for these examples can be found via the Tutorials and Examples link in the main Qt documentation. -- cgit v0.12 From 82e5ad18fdde7fba4146f28dec897328ec331dff Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Mon, 24 May 2010 16:36:56 +1000 Subject: Be slightly more verbose on assigning undefined in binding. Task-number: QTBUG-10303 --- src/declarative/qml/qdeclarativebinding.cpp | 4 +++- .../qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp | 10 +++++----- .../declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/declarative/qml/qdeclarativebinding.cpp b/src/declarative/qml/qdeclarativebinding.cpp index 8230941..7385728 100644 --- a/src/declarative/qml/qdeclarativebinding.cpp +++ b/src/declarative/qml/qdeclarativebinding.cpp @@ -191,7 +191,9 @@ void QDeclarativeBinding::update(QDeclarativePropertyPrivate::WriteFlags flags) data->error.setUrl(url); data->error.setLine(line); data->error.setColumn(-1); - data->error.setDescription(QLatin1String("Unable to assign [undefined] to ") + QLatin1String(QMetaType::typeName(data->property.propertyType()))); + data->error.setDescription(QLatin1String("Unable to assign [undefined] to ") + + QLatin1String(QMetaType::typeName(data->property.propertyType())) + + QLatin1String(" ") + data->property.name()); } else if (!scriptValue.isRegExp() && scriptValue.isFunction()) { diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp index 9a8ad64..e75abac 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -564,7 +564,7 @@ void tst_qdeclarativeecmascript::deferredPropertiesErrors() QVERIFY(object->objectProperty() == 0); QVERIFY(object->objectProperty2() == 0); - QString warning = component.url().toString() + ":6: Unable to assign [undefined] to QObject*"; + QString warning = component.url().toString() + ":6: Unable to assign [undefined] to QObject* objectProperty"; QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); qmlExecuteDeferred(object); @@ -642,8 +642,8 @@ void tst_qdeclarativeecmascript::enums() { QDeclarativeComponent component(&engine, TEST_FILE("enums.2.qml")); - QString warning1 = component.url().toString() + ":5: Unable to assign [undefined] to int"; - QString warning2 = component.url().toString() + ":6: Unable to assign [undefined] to int"; + QString warning1 = component.url().toString() + ":5: Unable to assign [undefined] to int a"; + QString warning2 = component.url().toString() + ":6: Unable to assign [undefined] to int b"; QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); @@ -754,7 +754,7 @@ void tst_qdeclarativeecmascript::nonExistantAttachedObject() { QDeclarativeComponent component(&engine, TEST_FILE("nonExistantAttachedObject.qml")); - QString warning = component.url().toString() + ":4: Unable to assign [undefined] to QString"; + QString warning = component.url().toString() + ":4: Unable to assign [undefined] to QString stringProperty"; QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); QObject *object = component.create(); @@ -1001,7 +1001,7 @@ void tst_qdeclarativeecmascript::scriptErrors() QString warning3 = url.left(url.length() - 3) + "js:4: Error: Invalid write to global property \"a\""; QString warning4 = url + ":10: TypeError: Result of expression 'a' [undefined] is not an object."; QString warning5 = url + ":8: TypeError: Result of expression 'a' [undefined] is not an object."; - QString warning6 = url + ":7: Unable to assign [undefined] to int"; + QString warning6 = url + ":7: Unable to assign [undefined] to int x"; QString warning7 = url + ":12: Error: Cannot assign to read-only property \"trueProperty\""; QString warning8 = url + ":13: Error: Cannot assign to non-existent property \"fakeProperty\""; diff --git a/tests/auto/declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp b/tests/auto/declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp index b0db771..0aebea1 100644 --- a/tests/auto/declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp +++ b/tests/auto/declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp @@ -266,7 +266,7 @@ void tst_qdeclarativeengine::outputWarningsToStandardError() delete o; QCOMPARE(warnings.count(), 1); - QCOMPARE(warnings.at(0), QLatin1String(":1: Unable to assign [undefined] to int")); + QCOMPARE(warnings.at(0), QLatin1String(":1: Unable to assign [undefined] to int a")); warnings.clear(); -- cgit v0.12 From 034641277fa71825470f1300f6950b97fdfd6098 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Mon, 24 May 2010 17:00:03 +1000 Subject: Remove incorrect ASSERT QTBUG-10832 --- src/declarative/qml/qdeclarativebinding.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/declarative/qml/qdeclarativebinding.cpp b/src/declarative/qml/qdeclarativebinding.cpp index 7385728..882e981 100644 --- a/src/declarative/qml/qdeclarativebinding.cpp +++ b/src/declarative/qml/qdeclarativebinding.cpp @@ -355,8 +355,6 @@ void QDeclarativeAbstractBinding::removeFromObject() if (m_prevBinding) { int index = propertyIndex(); - Q_ASSERT(m_object); - *m_prevBinding = m_nextBinding; if (m_nextBinding) m_nextBinding->m_prevBinding = m_prevBinding; m_prevBinding = 0; @@ -365,7 +363,7 @@ void QDeclarativeAbstractBinding::removeFromObject() if (index & 0xFF000000) { // Value type - we don't remove the proxy from the object. It will sit their happily // doing nothing for ever more. - } else { + } else if (m_object) { QDeclarativeData *data = QDeclarativeData::get(m_object, false); if (data) data->clearBindingBit(index); } -- cgit v0.12 From 4c975ee19b9671fbf76b546fc8ca2eff5bc69303 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Mon, 24 May 2010 17:11:00 +1000 Subject: Compiler warning QTBUG-10816 --- src/declarative/qml/qdeclarativeobjectscriptclass.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp index 8b64e0e..aca01b2 100644 --- a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp +++ b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp @@ -623,7 +623,7 @@ private: inline void cleanup(); - void *data[4]; + char data[4 * sizeof(void *)]; int type; }; } -- cgit v0.12