From 7f0b65bf04f96edf0d39547f499dea1746d69ba3 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Fri, 18 Dec 2009 11:04:50 +1000 Subject: Fix deferred property bugs Previously deferred properties would fail if any of the sub objects used bindings or QmlParserStatus. Whoops. --- src/declarative/qml/qmlcompiler.cpp | 8 + src/declarative/qml/qmlcomponent.cpp | 188 +++++++++++++-------- src/declarative/qml/qmlcomponent_p.h | 25 ++- src/declarative/qml/qmlcompositetypemanager.cpp | 2 +- src/declarative/qml/qmlengine.cpp | 16 +- src/declarative/qml/qmlengine_p.h | 2 +- src/declarative/qml/qmlinstruction.cpp | 2 +- src/declarative/qml/qmlvme.cpp | 1 - .../qmlecmascript/data/deferredProperties.qml | 5 +- tests/auto/declarative/qmlecmascript/testtypes.h | 15 +- .../qmlecmascript/tst_qmlecmascript.cpp | 3 + 11 files changed, 173 insertions(+), 94 deletions(-) diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp index 9147c4a..3f0dd84 100644 --- a/src/declarative/qml/qmlcompiler.cpp +++ b/src/declarative/qml/qmlcompiler.cpp @@ -902,6 +902,14 @@ void QmlCompiler::genObjectBody(QmlParser::Object *obj) int deferIdx = output->bytecode.count(); output->bytecode << defer; + QmlInstruction init; + init.type = QmlInstruction::Init; + init.init.bindingsSize = compileState.bindings.count(); // XXX - bigger than necessary + init.init.parserStatusSize = compileState.parserStatusCount; // XXX - bigger than necessary + init.init.contextCache = -1; + init.init.compiledBinding = -1; + output->bytecode << init; + foreach(Property *prop, obj->valueProperties) { if (!prop->isDeferred) continue; diff --git a/src/declarative/qml/qmlcomponent.cpp b/src/declarative/qml/qmlcomponent.cpp index 0bd51c3..2d53b0b 100644 --- a/src/declarative/qml/qmlcomponent.cpp +++ b/src/declarative/qml/qmlcomponent.cpp @@ -162,7 +162,7 @@ void QmlComponentPrivate::fromTypeData(QmlCompositeTypeData *data) if (!c) { Q_ASSERT(data->status == QmlCompositeTypeData::Error); - errors = data->errors; + state.errors = data->errors; } else { @@ -202,7 +202,7 @@ QmlComponent::~QmlComponent() { Q_D(QmlComponent); - if (d->completePending) { + if (d->state.completePending) { qWarning("QmlComponent: Component destroyed while completion pending"); d->completeCreate(); } @@ -213,11 +213,6 @@ QmlComponent::~QmlComponent() } if (d->cc) d->cc->release(); - - for(int ii = 0; ii < d->bindValues.count(); ++ii) - QmlEnginePrivate::clear(d->bindValues[ii]); - for(int ii = 0; ii < d->parserStatus.count(); ++ii) - QmlEnginePrivate::clear(d->parserStatus[ii]); } /*! @@ -230,7 +225,7 @@ QmlComponent::Status QmlComponent::status() const if (d->typeData) return Loading; - else if (!d->errors.isEmpty()) + else if (!d->state.errors.isEmpty()) return Error; else if (d->engine && d->cc) return Ready; @@ -483,7 +478,7 @@ QList QmlComponent::errors() const { Q_D(const QmlComponent); if (isError()) - return d->errors; + return d->state.errors; else return QList(); } @@ -498,7 +493,7 @@ QString QmlComponent::errorsString() const QString ret; if(!isError()) return ret; - foreach(const QmlError &e, d->errors) { + foreach(const QmlError &e, d->state.errors) { ret += e.url().toString() + QLatin1Char(':') + QString::number(e.line()) + QLatin1Char(' ') + e.description() + QLatin1Char('\n'); @@ -617,7 +612,7 @@ QmlComponentPrivate::beginCreate(QmlContext *context, const QBitField &bindings) return 0; } - if (completePending) { + if (state.completePending) { qWarning("QmlComponent: Cannot create new component instance before completing the previous"); return 0; } @@ -627,8 +622,7 @@ QmlComponentPrivate::beginCreate(QmlContext *context, const QBitField &bindings) return 0; } - if (!QmlEnginePrivate::get(engine)->rootComponent) - QmlEnginePrivate::get(engine)->rootComponent = q; + QmlEnginePrivate *ep = QmlEnginePrivate::get(engine); QmlContextPrivate *contextPriv = static_cast(QObjectPrivate::get(context)); @@ -637,29 +631,7 @@ QmlComponentPrivate::beginCreate(QmlContext *context, const QBitField &bindings) static_cast(ctxt->d_func())->imports = cc->importCache; cc->importCache->addref(); - QmlVME vme; - QObject *rv = vme.run(ctxt, cc, start, count, bindings); - - if (vme.isError()) - errors = vme.errors(); - - QmlEnginePrivate *ep = QmlEnginePrivate::get(engine); - if (ep->rootComponent == q) { - ep->rootComponent = 0; - - bindValues = ep->bindValues; - parserStatus = ep->parserStatus; - componentAttacheds = ep->componentAttacheds; - if (componentAttacheds) - componentAttacheds->prev = &componentAttacheds; - - ep->componentAttacheds = 0; - ep->bindValues.clear(); - ep->parserStatus.clear(); - completePending = true; - QmlEnginePrivate::get(engine)->inProgressCreations++; - } - + QObject *rv = begin(ctxt, ep, cc, start, count, &state, bindings); if (rv) { QmlGraphics_setParent_noEvent(ctxt, rv); @@ -672,40 +644,85 @@ QmlComponentPrivate::beginCreate(QmlContext *context, const QBitField &bindings) return rv; } -/*! - This method provides more advanced control over component instance creation. - In general, programmers should use QmlComponent::create() to create a - component. +QObject * QmlComponentPrivate::begin(QmlContext *ctxt, QmlEnginePrivate *enginePriv, + QmlCompiledData *component, int start, int count, + ConstructionState *state, const QBitField &bindings) +{ + bool isRoot = !enginePriv->inBeginCreate; + enginePriv->inBeginCreate = true; - Complete a component creation begin with QmlComponent::beginCreate(). -*/ -void QmlComponent::completeCreate() + QmlVME vme; + QObject *rv = vme.run(ctxt, component, start, count, bindings); + + if (vme.isError()) + state->errors = vme.errors(); + + if (isRoot) { + enginePriv->inBeginCreate = false; + + state->bindValues = enginePriv->bindValues; + state->parserStatus = enginePriv->parserStatus; + state->componentAttacheds = enginePriv->componentAttacheds; + if (state->componentAttacheds) + state->componentAttacheds->prev = &state->componentAttacheds; + + enginePriv->componentAttacheds = 0; + enginePriv->bindValues.clear(); + enginePriv->parserStatus.clear(); + state->completePending = true; + enginePriv->inProgressCreations++; + } + + return rv; +} + +void QmlComponentPrivate::beginDeferred(QmlContext *ctxt, QmlEnginePrivate *enginePriv, + QObject *object, ConstructionState *state) { - Q_D(QmlComponent); - d->completeCreate(); + bool isRoot = !enginePriv->inBeginCreate; + enginePriv->inBeginCreate = true; + + QmlVME vme; + vme.runDeferred(object); + + if (vme.isError()) + state->errors = vme.errors(); + + if (isRoot) { + enginePriv->inBeginCreate = false; + + state->bindValues = enginePriv->bindValues; + state->parserStatus = enginePriv->parserStatus; + state->componentAttacheds = enginePriv->componentAttacheds; + if (state->componentAttacheds) + state->componentAttacheds->prev = &state->componentAttacheds; + + enginePriv->componentAttacheds = 0; + enginePriv->bindValues.clear(); + enginePriv->parserStatus.clear(); + state->completePending = true; + enginePriv->inProgressCreations++; + } } -void QmlComponentPrivate::completeCreate() +void QmlComponentPrivate::complete(QmlEnginePrivate *enginePriv, ConstructionState *state) { - if (completePending) { - { -#ifdef Q_ENABLE_PERFORMANCE_LOG - QmlPerfTimer bi; -#endif - for (int ii = 0; ii < bindValues.count(); ++ii) { - QmlEnginePrivate::SimpleList bv = - bindValues.at(ii); - for (int jj = 0; jj < bv.count; ++jj) { - if(bv.at(jj)) - bv.at(jj)->setEnabled(true, QmlMetaProperty::BypassInterceptor | QmlMetaProperty::DontRemoveBinding); - } - QmlEnginePrivate::clear(bv); + if (state->completePending) { + + for (int ii = 0; ii < state->bindValues.count(); ++ii) { + QmlEnginePrivate::SimpleList bv = + state->bindValues.at(ii); + for (int jj = 0; jj < bv.count; ++jj) { + if(bv.at(jj)) + bv.at(jj)->setEnabled(true, QmlMetaProperty::BypassInterceptor | + QmlMetaProperty::DontRemoveBinding); } + QmlEnginePrivate::clear(bv); } - for (int ii = 0; ii < parserStatus.count(); ++ii) { + for (int ii = 0; ii < state->parserStatus.count(); ++ii) { QmlEnginePrivate::SimpleList ps = - parserStatus.at(ii); + state->parserStatus.at(ii); for (int jj = ps.count - 1; jj >= 0; --jj) { QmlParserStatus *status = ps.at(jj); @@ -717,28 +734,49 @@ void QmlComponentPrivate::completeCreate() QmlEnginePrivate::clear(ps); } - while (componentAttacheds) { - QmlComponentAttached *a = componentAttacheds; - if (a->next) a->next->prev = &componentAttacheds; - componentAttacheds = a->next; + while (state->componentAttacheds) { + QmlComponentAttached *a = state->componentAttacheds; + if (a->next) a->next->prev = &state->componentAttacheds; + state->componentAttacheds = a->next; a->prev = 0; a->next = 0; emit a->completed(); } - bindValues.clear(); - parserStatus.clear(); - completePending = false; - QmlEnginePrivate *p = QmlEnginePrivate::get(engine); - p->inProgressCreations--; - if (0 == p->inProgressCreations) { - while (p->erroredBindings) { - qWarning().nospace() << qPrintable(p->erroredBindings->error.toString()); - p->erroredBindings->removeError(); + state->bindValues.clear(); + state->parserStatus.clear(); + state->completePending = false; + + enginePriv->inProgressCreations--; + if (0 == enginePriv->inProgressCreations) { + while (enginePriv->erroredBindings) { + qWarning().nospace() << qPrintable(enginePriv->erroredBindings->error.toString()); + enginePriv->erroredBindings->removeError(); } } } } +/*! + This method provides more advanced control over component instance creation. + In general, programmers should use QmlComponent::create() to create a + component. + + Complete a component creation begin with QmlComponent::beginCreate(). +*/ +void QmlComponent::completeCreate() +{ + Q_D(QmlComponent); + d->completeCreate(); +} + +void QmlComponentPrivate::completeCreate() +{ + if (state.completePending) { + QmlEnginePrivate *ep = QmlEnginePrivate::get(engine); + complete(ep, &state); + } +} + QmlComponentAttached::QmlComponentAttached(QObject *parent) : QObject(parent), prev(0), next(0) { @@ -760,7 +798,7 @@ QmlComponentAttached *QmlComponent::qmlAttachedProperties(QObject *obj) QmlComponentAttached *a = new QmlComponentAttached(obj); QmlEngine *engine = qmlEngine(obj); - if (!engine || !QmlEnginePrivate::get(engine)->rootComponent) + if (!engine || !QmlEnginePrivate::get(engine)->inBeginCreate) return a; QmlEnginePrivate *p = QmlEnginePrivate::get(engine); diff --git a/src/declarative/qml/qmlcomponent_p.h b/src/declarative/qml/qmlcomponent_p.h index 1372d98..4039a61 100644 --- a/src/declarative/qml/qmlcomponent_p.h +++ b/src/declarative/qml/qmlcomponent_p.h @@ -79,8 +79,7 @@ class QmlComponentPrivate : public QObjectPrivate Q_DECLARE_PUBLIC(QmlComponent) public: - QmlComponentPrivate() : typeData(0), progress(0.), start(-1), count(-1), cc(0), componentAttacheds(0), completePending(false), engine(0), creationContext(0) {} - + QmlComponentPrivate() : typeData(0), progress(0.), start(-1), count(-1), cc(0), engine(0), creationContext(0) {} QObject *create(QmlContext *context, const QBitField &); QObject *beginCreate(QmlContext *, const QBitField &); @@ -92,7 +91,6 @@ public: void fromTypeData(QmlCompositeTypeData *data); - QList errors; QUrl url; qreal progress; @@ -100,11 +98,22 @@ public: int count; QmlCompiledData *cc; - QList > bindValues; - QList > parserStatus; - QmlComponentAttached *componentAttacheds; - - bool completePending; + struct ConstructionState { + ConstructionState() : componentAttacheds(0), completePending(false) {} + QList > bindValues; + QList > parserStatus; + QmlComponentAttached *componentAttacheds; + QList errors; + bool completePending; + }; + ConstructionState state; + + static QObject *begin(QmlContext *ctxt, QmlEnginePrivate *enginePriv, + QmlCompiledData *component, int start, int count, + ConstructionState *state, const QBitField &bindings = QBitField()); + static void beginDeferred(QmlContext *ctxt, QmlEnginePrivate *enginePriv, + QObject *object, ConstructionState *state); + static void complete(QmlEnginePrivate *enginePriv, ConstructionState *state); QmlEngine *engine; QmlContext *creationContext; diff --git a/src/declarative/qml/qmlcompositetypemanager.cpp b/src/declarative/qml/qmlcompositetypemanager.cpp index 9590718..d59fe4e 100644 --- a/src/declarative/qml/qmlcompositetypemanager.cpp +++ b/src/declarative/qml/qmlcompositetypemanager.cpp @@ -106,7 +106,7 @@ QmlComponent *QmlCompositeTypeData::toComponent(QmlEngine *engine) } else { component = new QmlComponent(engine, 0); component->d_func()->url = imports.baseUrl(); - component->d_func()->errors = errors; + component->d_func()->state.errors = errors; } } diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp index f541631..988962b 100644 --- a/src/declarative/qml/qmlengine.cpp +++ b/src/declarative/qml/qmlengine.cpp @@ -62,6 +62,7 @@ #include "qmlscriptstring.h" #include "qmlglobal_p.h" #include "qmlworkerscript_p.h" +#include "qmlcomponent_p.h" #include @@ -117,7 +118,7 @@ QmlEnginePrivate::QmlEnginePrivate(QmlEngine *e) isDebugging(false), contextClass(0), sharedContext(0), sharedScope(0), objectClass(0), valueTypeClass(0), globalClass(0), cleanup(0), erroredBindings(0), inProgressCreations(0), scriptEngine(this), workerScriptEngine(0), componentAttacheds(0), - rootComponent(0), networkAccessManager(0), typeManager(e), uniqueId(1) + inBeginCreate(false), networkAccessManager(0), typeManager(e), uniqueId(1) { globalClass = new QmlGlobalScriptClass(&scriptEngine); } @@ -495,11 +496,20 @@ void qmlExecuteDeferred(QObject *object) QmlDeclarativeData *data = QmlDeclarativeData::get(object); if (data && data->deferredComponent) { - QmlVME vme; - vme.runDeferred(object); + + QmlEnginePrivate *ep = QmlEnginePrivate::get(data->context->engine()); + + QmlComponentPrivate::ConstructionState state; + QmlComponentPrivate::beginDeferred(data->context, ep, object, &state); data->deferredComponent->release(); data->deferredComponent = 0; + + QmlComponentPrivate::complete(ep, &state); + + if (!state.errors.isEmpty()) + qWarning() << state.errors; + } } diff --git a/src/declarative/qml/qmlengine_p.h b/src/declarative/qml/qmlengine_p.h index 96297ea..8f2f0fb 100644 --- a/src/declarative/qml/qmlengine_p.h +++ b/src/declarative/qml/qmlengine_p.h @@ -205,7 +205,7 @@ public: QList > parserStatus; QmlComponentAttached *componentAttacheds; - QmlComponent *rootComponent; + bool inBeginCreate; mutable QNetworkAccessManager *networkAccessManager; QmlCompositeTypeManager typeManager; diff --git a/src/declarative/qml/qmlinstruction.cpp b/src/declarative/qml/qmlinstruction.cpp index 67db9c6..c873803 100644 --- a/src/declarative/qml/qmlinstruction.cpp +++ b/src/declarative/qml/qmlinstruction.cpp @@ -56,7 +56,7 @@ void QmlCompiledData::dump(QmlInstruction *instr, int idx) switch(instr->type) { case QmlInstruction::Init: - qWarning().nospace() << idx << "\t\t" << line << "\t" << "INIT"; + qWarning().nospace() << idx << "\t\t" << line << "\t" << "INIT\t\t\t" << instr->init.bindingsSize << "\t" << instr->init.parserStatusSize << "\t" << instr->init.contextCache << "\t" << instr->init.compiledBinding; break; case QmlInstruction::CreateObject: qWarning().nospace() << idx << "\t\t" << line << "\t" << "CREATE\t\t\t" << instr->create.type << "\t\t\t" << types.at(instr->create.type).className; diff --git a/src/declarative/qml/qmlvme.cpp b/src/declarative/qml/qmlvme.cpp index ae7bf51..58cd92f 100644 --- a/src/declarative/qml/qmlvme.cpp +++ b/src/declarative/qml/qmlvme.cpp @@ -131,7 +131,6 @@ void QmlVME::runDeferred(QObject *object) run(stack, ctxt, comp, start, count, QBitField()); } -QBitField bindingSkipList; QObject *QmlVME::run(QmlVMEStack &stack, QmlContext *ctxt, QmlCompiledData *comp, int start, int count, diff --git a/tests/auto/declarative/qmlecmascript/data/deferredProperties.qml b/tests/auto/declarative/qmlecmascript/data/deferredProperties.qml index 9dabafe..e01f708 100644 --- a/tests/auto/declarative/qmlecmascript/data/deferredProperties.qml +++ b/tests/auto/declarative/qmlecmascript/data/deferredProperties.qml @@ -1,7 +1,10 @@ import Qt.test 1.0 MyDeferredObject { + id: root value: 10 - objectProperty: MyQmlObject {} + objectProperty: MyQmlObject { + value: root.value + } objectProperty2: MyQmlObject { id: blah } } diff --git a/tests/auto/declarative/qmlecmascript/testtypes.h b/tests/auto/declarative/qmlecmascript/testtypes.h index ff20487..7c02995 100644 --- a/tests/auto/declarative/qmlecmascript/testtypes.h +++ b/tests/auto/declarative/qmlecmascript/testtypes.h @@ -67,13 +67,14 @@ class MyQmlObject : public QObject Q_PROPERTY(int deleteOnSet READ deleteOnSet WRITE setDeleteOnSet) Q_PROPERTY(bool trueProperty READ trueProperty CONSTANT) Q_PROPERTY(bool falseProperty READ falseProperty CONSTANT) + Q_PROPERTY(int value READ value WRITE setValue) Q_PROPERTY(QString stringProperty READ stringProperty WRITE setStringProperty NOTIFY stringChanged) Q_PROPERTY(QObject *objectProperty READ objectProperty WRITE setObjectProperty NOTIFY objectChanged) Q_PROPERTY(QmlList *objectQmlListProperty READ objectQmlListProperty CONSTANT) Q_PROPERTY(QList *objectListProperty READ objectListProperty CONSTANT) public: - MyQmlObject(): m_methodCalled(false), m_methodIntCalled(false), m_object(0) {} + MyQmlObject(): m_methodCalled(false), m_methodIntCalled(false), m_object(0), m_value(0) {} enum MyEnum { EnumValue1 = 0, EnumValue2 = 1 }; enum MyEnum2 { EnumValue3 = 2, EnumValue4 = 3 }; @@ -112,6 +113,9 @@ public: int deleteOnSet() const { return 1; } void setDeleteOnSet(int v) { if(v) delete this; } + + int value() const { return m_value; } + void setValue(int v) { m_value = v; } signals: void basicSignal(); void argumentSignal(int a, QString b, qreal c); @@ -135,6 +139,7 @@ private: QString m_string; QmlConcreteList m_objectQmlList; QList m_objectQList; + int m_value; }; QML_DECLARE_TYPEINFO(MyQmlObject, QML_HAS_ATTACHED_PROPERTIES) @@ -204,7 +209,7 @@ public: class MyDeferredObject : public QObject { Q_OBJECT - Q_PROPERTY(int value READ value WRITE setValue) + Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged) Q_PROPERTY(QObject *objectProperty READ objectProperty WRITE setObjectProperty); Q_PROPERTY(QObject *objectProperty2 READ objectProperty2 WRITE setObjectProperty2); Q_CLASSINFO("DeferredPropertyNames", "value,objectProperty,objectProperty2"); @@ -213,13 +218,17 @@ public: MyDeferredObject() : m_value(0), m_object(0), m_object2(0) {} int value() const { return m_value; } - void setValue(int v) { m_value = v; } + void setValue(int v) { m_value = v; emit valueChanged(); } QObject *objectProperty() const { return m_object; } void setObjectProperty(QObject *obj) { m_object = obj; } QObject *objectProperty2() const { return m_object2; } void setObjectProperty2(QObject *obj) { m_object2 = obj; } + +signals: + void valueChanged(); + private: int m_value; QObject *m_object; diff --git a/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp b/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp index b9a2241..24681b9 100644 --- a/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp +++ b/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp @@ -432,6 +432,9 @@ void tst_qmlecmascript::deferredProperties() MyQmlObject *qmlObject = qobject_cast(object->objectProperty()); QVERIFY(qmlObject != 0); + QCOMPARE(qmlObject->value(), 10); + object->setValue(19); + QCOMPARE(qmlObject->value(), 19); } void tst_qmlecmascript::extensionObjects() -- cgit v0.12 From 7cb8f90c27f29cee09bd81d747142842d809d775 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 18 Dec 2009 11:42:51 +1000 Subject: Have qmlInfo report the QML element name rather than C++ class name. Task-number: QTBUG-5476 --- src/declarative/qml/qmlinfo.cpp | 22 ++++++++++-- tests/auto/declarative/anchors/tst_anchors.cpp | 30 ++++++++-------- .../auto/declarative/animations/tst_animations.cpp | 24 ++++++------- tests/auto/declarative/behaviors/tst_behaviors.cpp | 2 +- .../declarative/qmllistmodel/tst_qmllistmodel.cpp | 42 +++++++++++----------- .../qmlxmllistmodel/tst_qmlxmllistmodel.cpp | 4 +-- tests/auto/declarative/states/tst_states.cpp | 8 ++--- 7 files changed, 74 insertions(+), 58 deletions(-) diff --git a/src/declarative/qml/qmlinfo.cpp b/src/declarative/qml/qmlinfo.cpp index 27f5426..dabf944 100644 --- a/src/declarative/qml/qmlinfo.cpp +++ b/src/declarative/qml/qmlinfo.cpp @@ -43,6 +43,7 @@ #include "qmldeclarativedata_p.h" #include "qmlcontext.h" +#include "qmlmetatype.h" #include @@ -53,7 +54,7 @@ QT_BEGIN_NAMESPACE \brief Prints warnings messages that include the file and line number for QML types. - When QML types display warning messages, it improves tracibility + When QML types display warning messages, it improves traceability if they include the QML file and line number on which the particular instance was instantiated. @@ -71,7 +72,7 @@ QT_BEGIN_NAMESPACE prints \code - QML ComponentInstance (unknown location): component property is a write-once property + QML MyCustomType (unknown location): component property is a write-once property \endcode */ @@ -81,7 +82,22 @@ QmlInfo::QmlInfo(const QObject *object) QString pos = QLatin1String("QML"); if (object) { pos += QLatin1Char(' '); - pos += QLatin1String(object->metaObject()->className()); + + QString typeName; + QmlType *type = QmlMetaType::qmlType(object->metaObject()); + if (type) { + typeName = QLatin1String(type->qmlTypeName()); + int lastSlash = typeName.lastIndexOf(QLatin1Char('/')); + if (lastSlash != -1) + typeName = typeName.mid(lastSlash+1); + } else { + typeName = QString::fromUtf8(object->metaObject()->className()); + int marker = typeName.indexOf(QLatin1String("_QMLTYPE_")); + if (marker != -1) + typeName = typeName.left(marker); + } + + pos += typeName; } QmlDeclarativeData *ddata = object?QmlDeclarativeData::get(object):0; pos += QLatin1String(" ("); diff --git a/tests/auto/declarative/anchors/tst_anchors.cpp b/tests/auto/declarative/anchors/tst_anchors.cpp index defc841..90a90fe 100644 --- a/tests/auto/declarative/anchors/tst_anchors.cpp +++ b/tests/auto/declarative/anchors/tst_anchors.cpp @@ -175,7 +175,7 @@ void tst_anchors::loops() view->setUrl(QUrl("file://" SRCDIR "/data/loop1.qml")); - QString expect = "QML QmlGraphicsText (" + view->url().toString() + ":6:5" + ") Possible anchor loop detected on horizontal anchor."; + QString expect = "QML Text (" + view->url().toString() + ":6:5" + ") Possible anchor loop detected on horizontal anchor."; QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); @@ -190,7 +190,7 @@ void tst_anchors::loops() view->setUrl(QUrl("file://" SRCDIR "/data/loop2.qml")); - QString expect = "QML QmlGraphicsImage (" + view->url().toString() + ":8:3" + ") Possible anchor loop detected on horizontal anchor."; + QString expect = "QML Image (" + view->url().toString() + ":8:3" + ") Possible anchor loop detected on horizontal anchor."; QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); view->execute(); qApp->processEvents(); @@ -222,55 +222,55 @@ void tst_anchors::illegalSets_data() QTest::newRow("H - too many anchors") << "Rectangle { id: rect; Rectangle { anchors.left: rect.left; anchors.right: rect.right; anchors.horizontalCenter: rect.horizontalCenter } }" - << "QML QmlGraphicsRectangle (file::2:23) Can't specify left, right, and hcenter anchors."; + << "QML Rectangle (file::2:23) Can't specify left, right, and hcenter anchors."; foreach (const QString &side, QStringList() << "left" << "right") { QTest::newRow("H - anchor to V") << QString("Rectangle { Rectangle { anchors.%1: parent.top } }").arg(side) - << "QML QmlGraphicsRectangle (file::2:13) Can't anchor a horizontal edge to a vertical edge."; + << "QML Rectangle (file::2:13) Can't anchor a horizontal edge to a vertical edge."; QTest::newRow("H - anchor to non parent/sibling") << QString("Rectangle { Item { Rectangle { id: rect } } Rectangle { anchors.%1: rect.%1 } }").arg(side) - << "QML QmlGraphicsRectangle (file::2:45) Can't anchor to an item that isn't a parent or sibling."; + << "QML Rectangle (file::2:45) Can't anchor to an item that isn't a parent or sibling."; QTest::newRow("H - anchor to self") << QString("Rectangle { id: rect; anchors.%1: rect.%1 }").arg(side) - << "QML QmlGraphicsRectangle (file::2:1) Can't anchor item to self."; + << "QML Rectangle (file::2:1) Can't anchor item to self."; } QTest::newRow("V - too many anchors") << "Rectangle { id: rect; Rectangle { anchors.top: rect.top; anchors.bottom: rect.bottom; anchors.verticalCenter: rect.verticalCenter } }" - << "QML QmlGraphicsRectangle (file::2:23) Can't specify top, bottom, and vcenter anchors."; + << "QML Rectangle (file::2:23) Can't specify top, bottom, and vcenter anchors."; QTest::newRow("V - too many anchors with baseline") << "Rectangle { Text { id: text1; text: \"Hello\" } Text { anchors.baseline: text1.baseline; anchors.top: text1.top; } }" - << "QML QmlGraphicsText (file::2:47) Baseline anchor can't be used in conjunction with top, bottom, or vcenter anchors."; + << "QML Text (file::2:47) Baseline anchor can't be used in conjunction with top, bottom, or vcenter anchors."; foreach (const QString &side, QStringList() << "top" << "bottom" << "baseline") { QTest::newRow("V - anchor to H") << QString("Rectangle { Rectangle { anchors.%1: parent.left } }").arg(side) - << "QML QmlGraphicsRectangle (file::2:13) Can't anchor a vertical edge to a horizontal edge."; + << "QML Rectangle (file::2:13) Can't anchor a vertical edge to a horizontal edge."; QTest::newRow("V - anchor to non parent/sibling") << QString("Rectangle { Item { Rectangle { id: rect } } Rectangle { anchors.%1: rect.%1 } }").arg(side) - << "QML QmlGraphicsRectangle (file::2:45) Can't anchor to an item that isn't a parent or sibling."; + << "QML Rectangle (file::2:45) Can't anchor to an item that isn't a parent or sibling."; QTest::newRow("V - anchor to self") << QString("Rectangle { id: rect; anchors.%1: rect.%1 }").arg(side) - << "QML QmlGraphicsRectangle (file::2:1) Can't anchor item to self."; + << "QML Rectangle (file::2:1) Can't anchor item to self."; } QTest::newRow("centerIn - anchor to non parent/sibling") << "Rectangle { Item { Rectangle { id: rect } } Rectangle { anchors.centerIn: rect} }" - << "QML QmlGraphicsRectangle (file::2:45) Can't anchor to an item that isn't a parent or sibling."; + << "QML Rectangle (file::2:45) Can't anchor to an item that isn't a parent or sibling."; QTest::newRow("fill - anchor to non parent/sibling") << "Rectangle { Item { Rectangle { id: rect } } Rectangle { anchors.fill: rect} }" - << "QML QmlGraphicsRectangle (file::2:45) Can't anchor to an item that isn't a parent or sibling."; + << "QML Rectangle (file::2:45) Can't anchor to an item that isn't a parent or sibling."; } void tst_anchors::reset() @@ -347,7 +347,7 @@ void tst_anchors::nullItem() const QMetaObject *meta = item->anchors()->metaObject(); QMetaProperty p = meta->property(meta->indexOfProperty(side.toUtf8().constData())); - QTest::ignoreMessage(QtWarningMsg, "QML QmlGraphicsItem (unknown location) Can't anchor to a null item."); + QTest::ignoreMessage(QtWarningMsg, "QML Item (unknown location) Can't anchor to a null item."); QVERIFY(p.write(item->anchors(), qVariantFromValue(anchor))); delete item; @@ -373,7 +373,7 @@ void tst_anchors::crash1() view->setUrl(QUrl("file://" SRCDIR "/data/crash1.qml")); - QString expect = "QML QmlGraphicsText (" + view->url().toString() + ":4:5" + ") Possible anchor loop detected on fill."; + QString expect = "QML Text (" + view->url().toString() + ":4:5" + ") Possible anchor loop detected on fill."; QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); view->execute(); qApp->processEvents(); diff --git a/tests/auto/declarative/animations/tst_animations.cpp b/tests/auto/declarative/animations/tst_animations.cpp index a6cb490..d9a81c4 100644 --- a/tests/auto/declarative/animations/tst_animations.cpp +++ b/tests/auto/declarative/animations/tst_animations.cpp @@ -297,12 +297,12 @@ void tst_animations::badProperties() QmlEngine engine; QmlComponent c1(&engine, QUrl("file://" SRCDIR "/data/badproperty1.qml")); - QTest::ignoreMessage(QtWarningMsg, "QML QmlColorAnimation (file://" SRCDIR "/data/badproperty1.qml:22:9) Cannot animate non-existant property \"border.colr\""); + QTest::ignoreMessage(QtWarningMsg, "QML ColorAnimation (file://" SRCDIR "/data/badproperty1.qml:22:9) Cannot animate non-existant property \"border.colr\""); QmlGraphicsRectangle *rect = qobject_cast(c1.create()); QVERIFY(rect); QmlComponent c2(&engine, QUrl("file://" SRCDIR "/data/badproperty2.qml")); - QTest::ignoreMessage(QtWarningMsg, "QML QmlColorAnimation (file://" SRCDIR "/data/badproperty2.qml:22:9) Cannot animate read-only property \"border\""); + QTest::ignoreMessage(QtWarningMsg, "QML ColorAnimation (file://" SRCDIR "/data/badproperty2.qml:22:9) Cannot animate read-only property \"border\""); rect = qobject_cast(c2.create()); QVERIFY(rect); @@ -454,7 +454,7 @@ void tst_animations::propertiesTransition() QmlGraphicsRectangle *myRect = rect->findChild("TheRect"); QVERIFY(myRect); - QTest::ignoreMessage(QtWarningMsg, "QML QmlNumberAnimation (file://" SRCDIR "/data/propertiesTransition4.qml:22:9) matchTargets/matchProperties/exclude and target/property are mutually exclusive."); + QTest::ignoreMessage(QtWarningMsg, "QML NumberAnimation (file://" SRCDIR "/data/propertiesTransition4.qml:22:9) matchTargets/matchProperties/exclude and target/property are mutually exclusive."); rect->setState("moved"); QCOMPARE(myRect->x(),qreal(200)); } @@ -467,7 +467,7 @@ void tst_animations::propertiesTransition() QmlGraphicsRectangle *myRect = rect->findChild("TheRect"); QVERIFY(myRect); - QTest::ignoreMessage(QtWarningMsg, "QML QmlNumberAnimation (file://" SRCDIR "/data/propertiesTransition5.qml:22:9) matchTargets/matchProperties/exclude and target/property are mutually exclusive."); + QTest::ignoreMessage(QtWarningMsg, "QML NumberAnimation (file://" SRCDIR "/data/propertiesTransition5.qml:22:9) matchTargets/matchProperties/exclude and target/property are mutually exclusive."); rect->setState("moved"); QCOMPARE(myRect->x(),qreal(200)); } @@ -509,28 +509,28 @@ void tst_animations::easingStringConversion() QCOMPARE(static_cast(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().type(), QEasingCurve::InOutBack); QCOMPARE(static_cast(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().overshoot(), qreal(2)); - QTest::ignoreMessage(QtWarningMsg, "QML QmlNumberAnimation (unknown location) Unmatched parenthesis in easing function \"easeInOutBack(overshoot: 2\""); + QTest::ignoreMessage(QtWarningMsg, "QML NumberAnimation (unknown location) Unmatched parenthesis in easing function \"easeInOutBack(overshoot: 2\""); animation->setEasing("easeInOutBack(overshoot: 2"); QCOMPARE(static_cast(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().type(), QEasingCurve::Linear); - QTest::ignoreMessage(QtWarningMsg, "QML QmlNumberAnimation (unknown location) Easing function \"InOutBack(overshoot: 2)\" must start with \"ease\""); + QTest::ignoreMessage(QtWarningMsg, "QML NumberAnimation (unknown location) Easing function \"InOutBack(overshoot: 2)\" must start with \"ease\""); animation->setEasing("InOutBack(overshoot: 2)"); QCOMPARE(static_cast(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().type(), QEasingCurve::Linear); - QTest::ignoreMessage(QtWarningMsg, "QML QmlNumberAnimation (unknown location) Unknown easing curve \"NonExistantEase\""); + QTest::ignoreMessage(QtWarningMsg, "QML NumberAnimation (unknown location) Unknown easing curve \"NonExistantEase\""); animation->setEasing("NonExistantEase"); QCOMPARE(static_cast(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().type(), QEasingCurve::Linear); - QTest::ignoreMessage(QtWarningMsg, "QML QmlNumberAnimation (unknown location) Improperly specified parameter in easing function \"easeInOutElastic(amplitude 5)\""); + QTest::ignoreMessage(QtWarningMsg, "QML NumberAnimation (unknown location) Improperly specified parameter in easing function \"easeInOutElastic(amplitude 5)\""); animation->setEasing("easeInOutElastic(amplitude 5)"); QCOMPARE(static_cast(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().type(), QEasingCurve::InOutElastic); - QTest::ignoreMessage(QtWarningMsg, "QML QmlNumberAnimation (unknown location) Improperly specified parameter in easing function \"easeInOutElastic(amplitude: yes)\""); + QTest::ignoreMessage(QtWarningMsg, "QML NumberAnimation (unknown location) Improperly specified parameter in easing function \"easeInOutElastic(amplitude: yes)\""); animation->setEasing("easeInOutElastic(amplitude: yes)"); QCOMPARE(static_cast(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().type(), QEasingCurve::InOutElastic); QVERIFY(static_cast(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().amplitude() != qreal(5)); - QTest::ignoreMessage(QtWarningMsg, "QML QmlNumberAnimation (unknown location) Unknown easing parameter \"nonexistantproperty\""); + QTest::ignoreMessage(QtWarningMsg, "QML NumberAnimation (unknown location) Unknown easing parameter \"nonexistantproperty\""); animation->setEasing("easeOutQuad(nonexistantproperty: 12)"); QCOMPARE(static_cast(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().type(), QEasingCurve::OutQuad); @@ -540,12 +540,12 @@ void tst_animations::easingStringConversion() void tst_animations::invalidDuration() { QmlPropertyAnimation *animation = new QmlPropertyAnimation; - QTest::ignoreMessage(QtWarningMsg, "QML QmlPropertyAnimation (unknown location) Cannot set a duration of < 0"); + QTest::ignoreMessage(QtWarningMsg, "QML PropertyAnimation (unknown location) Cannot set a duration of < 0"); animation->setDuration(-1); QCOMPARE(animation->duration(), 250); QmlPauseAnimation *pauseAnimation = new QmlPauseAnimation; - QTest::ignoreMessage(QtWarningMsg, "QML QmlPauseAnimation (unknown location) Cannot set a duration of < 0"); + QTest::ignoreMessage(QtWarningMsg, "QML PauseAnimation (unknown location) Cannot set a duration of < 0"); pauseAnimation->setDuration(-1); QCOMPARE(pauseAnimation->duration(), 250); } diff --git a/tests/auto/declarative/behaviors/tst_behaviors.cpp b/tests/auto/declarative/behaviors/tst_behaviors.cpp index e1376ce..fe6bc6f 100644 --- a/tests/auto/declarative/behaviors/tst_behaviors.cpp +++ b/tests/auto/declarative/behaviors/tst_behaviors.cpp @@ -236,7 +236,7 @@ void tst_behaviors::reassignedAnimation() { QmlEngine engine; QmlComponent c(&engine, QUrl("file://" SRCDIR "/data/reassignedAnimation.qml")); - QTest::ignoreMessage(QtWarningMsg, "QML QmlBehavior (file://" SRCDIR "/data/reassignedAnimation.qml:9:12) Can't change the animation assigned to a Behavior."); + QTest::ignoreMessage(QtWarningMsg, "QML Behavior (file://" SRCDIR "/data/reassignedAnimation.qml:9:12) Can't change the animation assigned to a Behavior."); QmlGraphicsRectangle *rect = qobject_cast(c.create()); QVERIFY(rect); QCOMPARE(qobject_cast( diff --git a/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp b/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp index c7de5d9..0d09b54 100644 --- a/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp +++ b/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp @@ -81,54 +81,54 @@ void tst_QmlListModel::dynamic_data() QTest::newRow("count") << "count" << 0 << ""; - QTest::newRow("get1") << "{get(0)}" << 0 << "QML QmlListModel (unknown location) get: index 0 out of range"; + QTest::newRow("get1") << "{get(0)}" << 0 << "QML ListModel (unknown location) get: index 0 out of range"; QTest::newRow("append1") << "{append({'foo':123});count}" << 1 << ""; QTest::newRow("append2") << "{append({'foo':123,'bar':456});count}" << 1 << ""; QTest::newRow("append3a") << "{append({'foo':123});append({'foo':456});get(0).foo}" << 123 << ""; QTest::newRow("append3b") << "{append({'foo':123});append({'foo':456});get(1).foo}" << 456 << ""; - QTest::newRow("append4a") << "{append(123)}" << 0 << "QML QmlListModel (unknown location) append: value is not an object"; - QTest::newRow("append4b") << "{append([1,2,3])}" << 0 << "QML QmlListModel (unknown location) append: value is not an object"; + QTest::newRow("append4a") << "{append(123)}" << 0 << "QML ListModel (unknown location) append: value is not an object"; + QTest::newRow("append4b") << "{append([1,2,3])}" << 0 << "QML ListModel (unknown location) append: value is not an object"; QTest::newRow("clear1") << "{append({'foo':456});clear();count}" << 0 << ""; QTest::newRow("clear2") << "{append({'foo':123});append({'foo':456});clear();count}" << 0 << ""; - QTest::newRow("clear2") << "{append({'foo':123});clear();get(0).foo}" << 0 << "QML QmlListModel (unknown location) get: index 0 out of range"; + QTest::newRow("clear2") << "{append({'foo':123});clear();get(0).foo}" << 0 << "QML ListModel (unknown location) get: index 0 out of range"; QTest::newRow("remove1") << "{append({'foo':123});remove(0);count}" << 0 << ""; QTest::newRow("remove2a") << "{append({'foo':123});append({'foo':456});remove(0);count}" << 1 << ""; QTest::newRow("remove2b") << "{append({'foo':123});append({'foo':456});remove(0);get(0).foo}" << 456 << ""; QTest::newRow("remove2c") << "{append({'foo':123});append({'foo':456});remove(1);get(0).foo}" << 123 << ""; - QTest::newRow("remove3") << "{append({'foo':123});remove(0);get(0).foo}" << 0 << "QML QmlListModel (unknown location) get: index 0 out of range"; - QTest::newRow("remove4a") << "{remove(0)}" << 0 << "QML QmlListModel (unknown location) remove: index 0 out of range"; - QTest::newRow("remove4b") << "{append({'foo':123});remove(0);remove(0)}" << 0 << "QML QmlListModel (unknown location) remove: index 0 out of range"; - QTest::newRow("remove4c") << "{append({'foo':123});remove(1)}" << 0 << "QML QmlListModel (unknown location) remove: index 1 out of range"; + QTest::newRow("remove3") << "{append({'foo':123});remove(0);get(0).foo}" << 0 << "QML ListModel (unknown location) get: index 0 out of range"; + QTest::newRow("remove4a") << "{remove(0)}" << 0 << "QML ListModel (unknown location) remove: index 0 out of range"; + QTest::newRow("remove4b") << "{append({'foo':123});remove(0);remove(0)}" << 0 << "QML ListModel (unknown location) remove: index 0 out of range"; + QTest::newRow("remove4c") << "{append({'foo':123});remove(1)}" << 0 << "QML ListModel (unknown location) remove: index 1 out of range"; QTest::newRow("insert1") << "{insert(0,{'foo':123});count}" << 1 << ""; - QTest::newRow("insert2") << "{insert(1,{'foo':123});count}" << 0 << "QML QmlListModel (unknown location) insert: index 1 out of range"; + QTest::newRow("insert2") << "{insert(1,{'foo':123});count}" << 0 << "QML ListModel (unknown location) insert: index 1 out of range"; QTest::newRow("insert3a") << "{append({'foo':123});insert(1,{'foo':456});count}" << 2 << ""; QTest::newRow("insert3b") << "{append({'foo':123});insert(1,{'foo':456});get(0).foo}" << 123 << ""; QTest::newRow("insert3c") << "{append({'foo':123});insert(1,{'foo':456});get(1).foo}" << 456 << ""; QTest::newRow("insert3d") << "{append({'foo':123});insert(0,{'foo':456});get(0).foo}" << 456 << ""; QTest::newRow("insert3e") << "{append({'foo':123});insert(0,{'foo':456});get(1).foo}" << 123 << ""; - QTest::newRow("insert4") << "{append({'foo':123});insert(-1,{'foo':456})}" << 0 << "QML QmlListModel (unknown location) insert: index -1 out of range"; - QTest::newRow("insert5a") << "{insert(0,123)}" << 0 << "QML QmlListModel (unknown location) insert: value is not an object"; - QTest::newRow("insert5b") << "{insert(0,[1,2,3])}" << 0 << "QML QmlListModel (unknown location) insert: value is not an object"; + QTest::newRow("insert4") << "{append({'foo':123});insert(-1,{'foo':456})}" << 0 << "QML ListModel (unknown location) insert: index -1 out of range"; + QTest::newRow("insert5a") << "{insert(0,123)}" << 0 << "QML ListModel (unknown location) insert: value is not an object"; + QTest::newRow("insert5b") << "{insert(0,[1,2,3])}" << 0 << "QML ListModel (unknown location) insert: value is not an object"; QTest::newRow("set1") << "{append({'foo':123});set(0,{'foo':456});count}" << 1 << ""; QTest::newRow("set2") << "{append({'foo':123});set(0,{'foo':456});get(0).foo}" << 456 << ""; QTest::newRow("set3a") << "{append({'foo':123,'bar':456});set(0,{'foo':999});get(0).foo}" << 999 << ""; QTest::newRow("set3b") << "{append({'foo':123,'bar':456});set(0,{'foo':999});get(0).bar}" << 456 << ""; - QTest::newRow("set4a") << "{set(0,{'foo':456})}" << 0 << "QML QmlListModel (unknown location) set: index 0 out of range"; - QTest::newRow("set5a") << "{append({'foo':123,'bar':456});set(0,123)}" << 0 << "QML QmlListModel (unknown location) set: value is not an object"; - QTest::newRow("set5b") << "{append({'foo':123,'bar':456});set(0,[1,2,3])}" << 0 << "QML QmlListModel (unknown location) set: value is not an object"; + QTest::newRow("set4a") << "{set(0,{'foo':456})}" << 0 << "QML ListModel (unknown location) set: index 0 out of range"; + QTest::newRow("set5a") << "{append({'foo':123,'bar':456});set(0,123)}" << 0 << "QML ListModel (unknown location) set: value is not an object"; + QTest::newRow("set5b") << "{append({'foo':123,'bar':456});set(0,[1,2,3])}" << 0 << "QML ListModel (unknown location) set: value is not an object"; QTest::newRow("set6") << "{append({'foo':123});set(1,{'foo':456});count}" << 2 << ""; QTest::newRow("setprop1") << "{append({'foo':123});set(0,'foo',456);count}" << 1 << ""; QTest::newRow("setprop2") << "{append({'foo':123});set(0,'foo',456);get(0).foo}" << 456 << ""; QTest::newRow("setprop3a") << "{append({'foo':123,'bar':456});set(0,'foo',999);get(0).foo}" << 999 << ""; QTest::newRow("setprop3b") << "{append({'foo':123,'bar':456});set(0,'foo',999);get(0).bar}" << 456 << ""; - QTest::newRow("setprop4a") << "{set(0,'foo',456)}" << 0 << "QML QmlListModel (unknown location) set: index 0 out of range"; - QTest::newRow("setprop4a") << "{append({'foo':123,'bar':456});set(1,'foo',456)}" << 0 << "QML QmlListModel (unknown location) set: index 1 out of range"; + QTest::newRow("setprop4a") << "{set(0,'foo',456)}" << 0 << "QML ListModel (unknown location) set: index 0 out of range"; + QTest::newRow("setprop4a") << "{append({'foo':123,'bar':456});set(1,'foo',456)}" << 0 << "QML ListModel (unknown location) set: index 1 out of range"; QTest::newRow("setprop5") << "{append({'foo':123,'bar':456});append({'foo':111});set(1,'bar',222);get(1).bar}" << 222 << ""; QTest::newRow("move1a") << "{append({'foo':123});append({'foo':456});move(0,1,1);count}" << 2 << ""; @@ -140,10 +140,10 @@ void tst_QmlListModel::dynamic_data() QTest::newRow("move2b") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,1,2);get(0).foo}" << 789 << ""; QTest::newRow("move2c") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,1,2);get(1).foo}" << 123 << ""; QTest::newRow("move2d") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,1,2);get(2).foo}" << 456 << ""; - QTest::newRow("move3a") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(1,0,3)}" << 0 << "QML QmlListModel (unknown location) move: out of range"; - QTest::newRow("move3b") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(1,-1,1)}" << 0 << "QML QmlListModel (unknown location) move: out of range"; - QTest::newRow("move3c") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(1,0,-1)}" << 0 << "QML QmlListModel (unknown location) move: out of range"; - QTest::newRow("move3d") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,3,1)}" << 0 << "QML QmlListModel (unknown location) move: out of range"; + QTest::newRow("move3a") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(1,0,3)}" << 0 << "QML ListModel (unknown location) move: out of range"; + QTest::newRow("move3b") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(1,-1,1)}" << 0 << "QML ListModel (unknown location) move: out of range"; + QTest::newRow("move3c") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(1,0,-1)}" << 0 << "QML ListModel (unknown location) move: out of range"; + QTest::newRow("move3d") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,3,1)}" << 0 << "QML ListModel (unknown location) move: out of range"; // Structured model diff --git a/tests/auto/declarative/qmlxmllistmodel/tst_qmlxmllistmodel.cpp b/tests/auto/declarative/qmlxmllistmodel/tst_qmlxmllistmodel.cpp index a68006d..af4bcda 100644 --- a/tests/auto/declarative/qmlxmllistmodel/tst_qmlxmllistmodel.cpp +++ b/tests/auto/declarative/qmlxmllistmodel/tst_qmlxmllistmodel.cpp @@ -156,7 +156,7 @@ void tst_qmlxmllistmodel::roles() void tst_qmlxmllistmodel::roleErrors() { QmlComponent component(&engine, QUrl("file://" SRCDIR "/data/roleErrors.qml")); - QTest::ignoreMessage(QtWarningMsg, "QML QmlXmlListModelRole (file://" SRCDIR "/data/roleErrors.qml:6:5) An XmlRole query must not start with '/'"); + QTest::ignoreMessage(QtWarningMsg, "QML XmlRole (file://" SRCDIR "/data/roleErrors.qml:6:5) An XmlRole query must not start with '/'"); //### make sure we receive all expected warning messages. QmlXmlListModel *listModel = qobject_cast(component.create()); QVERIFY(listModel != 0); @@ -179,7 +179,7 @@ void tst_qmlxmllistmodel::roleErrors() void tst_qmlxmllistmodel::uniqueRoleNames() { QmlComponent component(&engine, QUrl("file://" SRCDIR "/data/unique.qml")); - QTest::ignoreMessage(QtWarningMsg, "QML QmlXmlListModelRole (file://" SRCDIR "/data/unique.qml:7:5) \"name\" duplicates a previous role name and will be disabled."); + QTest::ignoreMessage(QtWarningMsg, "QML XmlRole (file://" SRCDIR "/data/unique.qml:7:5) \"name\" duplicates a previous role name and will be disabled."); QmlXmlListModel *listModel = qobject_cast(component.create()); QVERIFY(listModel != 0); QTRY_COMPARE(listModel->count(), 9); diff --git a/tests/auto/declarative/states/tst_states.cpp b/tests/auto/declarative/states/tst_states.cpp index 17d9263..9d9cf07 100644 --- a/tests/auto/declarative/states/tst_states.cpp +++ b/tests/auto/declarative/states/tst_states.cpp @@ -460,7 +460,7 @@ void tst_states::parentChangeErrors() QmlGraphicsRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); QVERIFY(innerRect != 0); - QTest::ignoreMessage(QtWarningMsg, "QML QmlParentChange (file://" SRCDIR "/data/parentChange4.qml:25:9) Unable to preserve appearance under non-uniform scale"); + QTest::ignoreMessage(QtWarningMsg, "QML ParentChange (file://" SRCDIR "/data/parentChange4.qml:25:9) Unable to preserve appearance under non-uniform scale"); rect->setState("reparented"); QCOMPARE(innerRect->rotation(), qreal(0)); QCOMPARE(innerRect->scale(), qreal(1)); @@ -476,7 +476,7 @@ void tst_states::parentChangeErrors() QmlGraphicsRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); QVERIFY(innerRect != 0); - QTest::ignoreMessage(QtWarningMsg, "QML QmlParentChange (file://" SRCDIR "/data/parentChange5.qml:25:9) Unable to preserve appearance under complex transform"); + QTest::ignoreMessage(QtWarningMsg, "QML ParentChange (file://" SRCDIR "/data/parentChange5.qml:25:9) Unable to preserve appearance under complex transform"); rect->setState("reparented"); QCOMPARE(innerRect->rotation(), qreal(0)); QCOMPARE(innerRect->scale(), qreal(1)); @@ -712,8 +712,8 @@ void tst_states::propertyErrors() QCOMPARE(rect->color(),QColor("red")); - QTest::ignoreMessage(QtWarningMsg, "QML QmlPropertyChanges (file://" SRCDIR "/data/propertyErrors.qml:8:9) Cannot assign to non-existant property \"colr\""); - QTest::ignoreMessage(QtWarningMsg, "QML QmlPropertyChanges (file://" SRCDIR "/data/propertyErrors.qml:8:9) Cannot assign to read-only property \"wantsFocus\""); + QTest::ignoreMessage(QtWarningMsg, "QML PropertyChanges (file://" SRCDIR "/data/propertyErrors.qml:8:9) Cannot assign to non-existant property \"colr\""); + QTest::ignoreMessage(QtWarningMsg, "QML PropertyChanges (file://" SRCDIR "/data/propertyErrors.qml:8:9) Cannot assign to read-only property \"wantsFocus\""); rect->setState("blue"); } -- cgit v0.12 From b6ce2683fd8f01ef58d7e9caad133ee6cb9e2ed9 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Fri, 18 Dec 2009 11:55:53 +1000 Subject: Deferred properties are off by default --- src/declarative/qml/qmlcompiler.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp index 3f0dd84..6ecb647 100644 --- a/src/declarative/qml/qmlcompiler.cpp +++ b/src/declarative/qml/qmlcompiler.cpp @@ -83,6 +83,7 @@ QT_BEGIN_NAMESPACE DEFINE_BOOL_CONFIG_OPTION(compilerDump, QML_COMPILER_DUMP); DEFINE_BOOL_CONFIG_OPTION(compilerStatDump, QML_COMPILER_STATISTICS_DUMP); DEFINE_BOOL_CONFIG_OPTION(qmlExperimental, QML_EXPERIMENTAL); +DEFINE_BOOL_CONFIG_OPTION(qmlEnableDeferred, QML_ENABLE_DEFERRED); using namespace QmlParser; @@ -2767,6 +2768,9 @@ QmlType *QmlCompiler::toQmlType(QmlParser::Object *from) QStringList QmlCompiler::deferredProperties(QmlParser::Object *obj) { + if (!qmlEnableDeferred()) + return QStringList(); + const QMetaObject *mo = obj->metatype; int idx = mo->indexOfClassInfo("DeferredPropertyNames"); -- cgit v0.12 From 88751e0dcad05cc68cf5160660151287db6e6273 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Fri, 18 Dec 2009 11:56:06 +1000 Subject: Use deferred properties in states and transitions --- src/declarative/util/qmlstate.cpp | 2 ++ src/declarative/util/qmlstate_p.h | 1 + src/declarative/util/qmltransition.cpp | 2 ++ src/declarative/util/qmltransition_p.h | 1 + 4 files changed, 6 insertions(+) diff --git a/src/declarative/util/qmlstate.cpp b/src/declarative/util/qmlstate.cpp index c2201a6..e41cbaf 100644 --- a/src/declarative/util/qmlstate.cpp +++ b/src/declarative/util/qmlstate.cpp @@ -329,6 +329,8 @@ void QmlState::apply(QmlStateGroup *group, QmlTransition *trans, QmlState *rever { Q_D(QmlState); + qmlExecuteDeferred(this); + cancel(); if (revert) revert->cancel(); diff --git a/src/declarative/util/qmlstate_p.h b/src/declarative/util/qmlstate_p.h index 33e66d8..95a6fc5 100644 --- a/src/declarative/util/qmlstate_p.h +++ b/src/declarative/util/qmlstate_p.h @@ -133,6 +133,7 @@ class Q_DECLARATIVE_EXPORT QmlState : public QObject Q_PROPERTY(QString extend READ extends WRITE setExtends) Q_PROPERTY(QmlList* changes READ changes) Q_CLASSINFO("DefaultProperty", "changes") + Q_CLASSINFO("DeferredPropertyNames", "changes"); public: QmlState(QObject *parent=0); diff --git a/src/declarative/util/qmltransition.cpp b/src/declarative/util/qmltransition.cpp index b96ff61..215fc91 100644 --- a/src/declarative/util/qmltransition.cpp +++ b/src/declarative/util/qmltransition.cpp @@ -165,6 +165,8 @@ void QmlTransition::prepare(QmlStateOperation::ActionList &actions, { Q_D(QmlTransition); + qmlExecuteDeferred(this); + if (d->reversed) { for (int ii = d->animations.count() - 1; ii >= 0; --ii) { d->animations.at(ii)->transition(actions, after, QmlAbstractAnimation::Backward); diff --git a/src/declarative/util/qmltransition_p.h b/src/declarative/util/qmltransition_p.h index 3dd0244..0a9b036 100644 --- a/src/declarative/util/qmltransition_p.h +++ b/src/declarative/util/qmltransition_p.h @@ -67,6 +67,7 @@ class Q_DECLARATIVE_EXPORT QmlTransition : public QObject Q_PROPERTY(bool reversible READ reversible WRITE setReversible) Q_PROPERTY(QmlList* animations READ animations) Q_CLASSINFO("DefaultProperty", "animations") + Q_CLASSINFO("DeferredPropertyNames", "animations"); public: QmlTransition(QObject *parent=0); -- cgit v0.12 From 32bcf89a330d422b0b99ac9090b104016418d07f Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Fri, 18 Dec 2009 13:34:53 +1000 Subject: Support binding optimizer and deferred properties --- src/declarative/qml/qmlcontext.cpp | 5 ++++- src/declarative/qml/qmlcontext_p.h | 4 ++++ src/declarative/qml/qmlvme.cpp | 11 ++--------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/declarative/qml/qmlcontext.cpp b/src/declarative/qml/qmlcontext.cpp index 49bb59c..4467cce 100644 --- a/src/declarative/qml/qmlcontext.cpp +++ b/src/declarative/qml/qmlcontext.cpp @@ -59,7 +59,7 @@ QT_BEGIN_NAMESPACE QmlContextPrivate::QmlContextPrivate() : parent(0), engine(0), isInternal(false), propertyNames(0), notifyIndex(-1), highPriorityCount(0), imports(0), expressions(0), contextObjects(0), - idValues(0), idValueCount(0) + idValues(0), idValueCount(0), optimizedBindings(0) { } @@ -303,6 +303,9 @@ QmlContext::~QmlContext() if (d->imports) d->imports->release(); + + if (d->optimizedBindings) + d->optimizedBindings->release(); } void QmlContextPrivate::invalidateEngines() diff --git a/src/declarative/qml/qmlcontext_p.h b/src/declarative/qml/qmlcontext_p.h index 35971d9..25f5600 100644 --- a/src/declarative/qml/qmlcontext_p.h +++ b/src/declarative/qml/qmlcontext_p.h @@ -76,6 +76,7 @@ class QmlExpression; class QmlExpressionPrivate; class QmlAbstractExpression; class QmlBinding_Id; +class QmlOptimizedBindings; class Q_DECLARATIVE_EXPORT QmlContextPrivate : public QObjectPrivate { @@ -133,6 +134,9 @@ public: static QmlContext *get(QmlContextPrivate *context) { return static_cast(context->q_func()); } + + QmlOptimizedBindings *optimizedBindings; + // Only used for debugging QList > instances; }; diff --git a/src/declarative/qml/qmlvme.cpp b/src/declarative/qml/qmlvme.cpp index 58cd92f..f1abd7d 100644 --- a/src/declarative/qml/qmlvme.cpp +++ b/src/declarative/qml/qmlvme.cpp @@ -160,8 +160,6 @@ QObject *QmlVME::run(QmlVMEStack &stack, QmlContext *ctxt, int status = -1; //for dbus QmlMetaProperty::WriteFlags flags = QmlMetaProperty::BypassInterceptor; - QmlOptimizedBindings *optimizedBindings = 0; - for (int ii = start; !isError() && ii < (start + count); ++ii) { const QmlInstruction &instr = comp->bytecode.at(ii); @@ -175,7 +173,7 @@ QObject *QmlVME::run(QmlVMEStack &stack, QmlContext *ctxt, if (instr.init.contextCache != -1) cp->setIdPropertyData(comp->contextCaches.at(instr.init.contextCache)); if (instr.init.compiledBinding != -1) - optimizedBindings = new QmlOptimizedBindings(datas.at(instr.init.compiledBinding).constData(), ctxt); + cp->optimizedBindings = new QmlOptimizedBindings(datas.at(instr.init.compiledBinding).constData(), ctxt); } break; @@ -622,7 +620,7 @@ QObject *QmlVME::run(QmlVMEStack &stack, QmlContext *ctxt, break; QmlAbstractBinding *binding = - optimizedBindings->configBinding(instr.assignBinding.value, target, scope, property); + cp->optimizedBindings->configBinding(instr.assignBinding.value, target, scope, property); bindValues.append(binding); binding->m_mePtr = &bindValues.values[bindValues.count - 1]; binding->addToObject(target); @@ -894,11 +892,6 @@ QObject *QmlVME::run(QmlVMEStack &stack, QmlContext *ctxt, } } - if (optimizedBindings) { - optimizedBindings->release(); - optimizedBindings = 0; - } - if (isError()) { if (!stack.isEmpty()) { delete stack.at(0); -- cgit v0.12 From 30b1c6d50f6f6ed1c77e03adb9f0c12cd3f94670 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Fri, 18 Dec 2009 13:37:26 +1000 Subject: Remove QML_ENABLE_DEFERRED env variable Use QML_EXPERIMENTAL instead --- src/declarative/qml/qmlcompiler.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp index 6ecb647..3ebefea 100644 --- a/src/declarative/qml/qmlcompiler.cpp +++ b/src/declarative/qml/qmlcompiler.cpp @@ -83,7 +83,6 @@ QT_BEGIN_NAMESPACE DEFINE_BOOL_CONFIG_OPTION(compilerDump, QML_COMPILER_DUMP); DEFINE_BOOL_CONFIG_OPTION(compilerStatDump, QML_COMPILER_STATISTICS_DUMP); DEFINE_BOOL_CONFIG_OPTION(qmlExperimental, QML_EXPERIMENTAL); -DEFINE_BOOL_CONFIG_OPTION(qmlEnableDeferred, QML_ENABLE_DEFERRED); using namespace QmlParser; @@ -2768,7 +2767,7 @@ QmlType *QmlCompiler::toQmlType(QmlParser::Object *from) QStringList QmlCompiler::deferredProperties(QmlParser::Object *obj) { - if (!qmlEnableDeferred()) + if (!qmlExperimental()) return QStringList(); const QMetaObject *mo = obj->metatype; -- cgit v0.12