From 092b4469b1e54c47d3baa615b9d1df5ed10bb10b Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Mon, 11 Jan 2010 17:59:10 +1000 Subject: Crash --- src/declarative/qml/qmlbindingvme.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/declarative/qml/qmlbindingvme.cpp b/src/declarative/qml/qmlbindingvme.cpp index 29391a6..493aeaf 100644 --- a/src/declarative/qml/qmlbindingvme.cpp +++ b/src/declarative/qml/qmlbindingvme.cpp @@ -570,7 +570,6 @@ inline static qreal toReal(Register *reg, int type, bool *ok = 0) if (type == QMetaType::QReal) { return reg->getqreal(); } else if (type == qMetaTypeId()) { - *ok = true; return reg->getvariantptr()->toReal(); } else { if (ok) *ok = false; -- cgit v0.12 From e9e94a3f6c77735e65353c78075cb411ba747f63 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Mon, 11 Jan 2010 19:01:26 +1000 Subject: More binding opts --- src/declarative/qml/qmlbindingvme.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/declarative/qml/qmlbindingvme.cpp b/src/declarative/qml/qmlbindingvme.cpp index 493aeaf..81e05c1 100644 --- a/src/declarative/qml/qmlbindingvme.cpp +++ b/src/declarative/qml/qmlbindingvme.cpp @@ -472,6 +472,19 @@ static bool findproperty(QObject *obj, Register *output, void *args[] = { output->typeDataPtr(), 0 }; QMetaObject::metacall(obj, QMetaObject::ReadProperty, property->coreIndex, args); output->settype(QMetaType::QReal); + } else if (property->propType == QMetaType::Int) { + void *args[] = { output->typeDataPtr(), 0 }; + QMetaObject::metacall(obj, QMetaObject::ReadProperty, property->coreIndex, args); + output->settype(QMetaType::Int); + } else if (property->propType == QMetaType::Bool) { + void *args[] = { output->typeDataPtr(), 0 }; + QMetaObject::metacall(obj, QMetaObject::ReadProperty, property->coreIndex, args); + output->settype(QMetaType::Bool); + } else if (property->propType == QMetaType::QString) { + new (output->typeDataPtr()) QString(); + void *args[] = { output->typeDataPtr(), 0 }; + QMetaObject::metacall(obj, QMetaObject::ReadProperty, property->coreIndex, args); + output->settype(QMetaType::QString); } else { new (output->typeDataPtr()) QVariant(obj->metaObject()->property(property->coreIndex).read(obj)); @@ -623,6 +636,8 @@ inline static QUrl toUrl(Register *reg, int type, QmlContextPrivate *context, bo if (ok) *ok = false; return QUrl(); } + } else if (type == QMetaType::QString) { + base = QUrl(*reg->getstringptr()); } else { if (ok) *ok = false; return QUrl(); @@ -881,6 +896,8 @@ void QmlBindingVME::run(const char *programData, int instrIndex, int type = registers[instr->cleanup.reg].gettype(); if (type == qMetaTypeId()) { ((QVariant *)registers[instr->cleanup.reg].typeDataPtr())->~QVariant(); + } else if (type == QMetaType::QString) { + ((QString *)registers[instr->cleanup.reg].typeDataPtr())->~QString(); } } break; -- cgit v0.12 From aa01490d56c8002a3b782b9016ba6eecefd1ef35 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Mon, 11 Jan 2010 11:44:16 +0100 Subject: Doc fixes Explictly mention that root items in delegates need a size. --- src/declarative/graphicsitems/qmlgraphicsgridview.cpp | 3 +++ src/declarative/graphicsitems/qmlgraphicslistview.cpp | 3 +++ src/declarative/graphicsitems/qmlgraphicspathview.cpp | 3 +++ 3 files changed, 9 insertions(+) diff --git a/src/declarative/graphicsitems/qmlgraphicsgridview.cpp b/src/declarative/graphicsitems/qmlgraphicsgridview.cpp index 0ba1491..2fad3bb 100644 --- a/src/declarative/graphicsitems/qmlgraphicsgridview.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsgridview.cpp @@ -874,6 +874,9 @@ void QmlGraphicsGridView::setModel(const QVariant &model) The index is exposed as an accessible \c index property. Properties of the model are also available depending upon the type of \l {qmlmodels}{Data Model}. + Note that the GridView will layout the items based on the size of the root item + in the delegate. + Here is an example delegate: \snippet doc/src/snippets/declarative/gridview/gridview.qml 0 */ diff --git a/src/declarative/graphicsitems/qmlgraphicslistview.cpp b/src/declarative/graphicsitems/qmlgraphicslistview.cpp index 6460a69..3a59c6c 100644 --- a/src/declarative/graphicsitems/qmlgraphicslistview.cpp +++ b/src/declarative/graphicsitems/qmlgraphicslistview.cpp @@ -1554,6 +1554,9 @@ void QmlGraphicsListView::setModel(const QVariant &model) The index is exposed as an accessible \c index property. Properties of the model are also available depending upon the type of \l {qmlmodels}{Data Model}. + Note that the ListView will layout the items based on the size of the root item + in the delegate. + Here is an example delegate: \snippet doc/src/snippets/declarative/listview/listview.qml 0 */ diff --git a/src/declarative/graphicsitems/qmlgraphicspathview.cpp b/src/declarative/graphicsitems/qmlgraphicspathview.cpp index b9c9e05..8ac57e0 100644 --- a/src/declarative/graphicsitems/qmlgraphicspathview.cpp +++ b/src/declarative/graphicsitems/qmlgraphicspathview.cpp @@ -302,6 +302,9 @@ void QmlGraphicsPathView::setDragMargin(qreal dragMargin) The index is exposed as an accessible \c index property. Properties of the model are also available depending upon the type of \l {qmlmodels}{Data Model}. + Note that the PathView will layout the items based on the size of the root + item in the delegate. + Here is an example delegate: \snippet doc/src/snippets/declarative/pathview/pathview.qml 1 */ -- cgit v0.12 From 98bb02c3210f29dfdc5fb0d82442779fa09dec94 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Mon, 11 Jan 2010 22:17:41 +1000 Subject: Crash --- src/declarative/qml/qmltypenamescriptclass.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/declarative/qml/qmltypenamescriptclass.cpp b/src/declarative/qml/qmltypenamescriptclass.cpp index c4c5f53..3e4b08c 100644 --- a/src/declarative/qml/qmltypenamescriptclass.cpp +++ b/src/declarative/qml/qmltypenamescriptclass.cpp @@ -147,7 +147,7 @@ QmlTypeNameScriptClass::Value QmlTypeNameScriptClass::property(Object *obj, cons } else if (object) { return ep->objectClass->property(object, name); } else { - return QScriptValue(enumValue); + return Value(&ep->scriptEngine, enumValue); } } -- cgit v0.12 From c0c2352a287348469617811985d773ec4c3d1875 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Tue, 12 Jan 2010 10:27:33 +1000 Subject: Cached programs and closures must be destroyed at shutdown --- src/declarative/qml/qmlcompileddata.cpp | 15 +++++++++++++-- src/declarative/qml/qmlcompiler_p.h | 8 ++++++-- src/declarative/qml/qmlcompositetypemanager.cpp | 2 +- src/declarative/qml/qmldom.cpp | 2 +- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/declarative/qml/qmlcompileddata.cpp b/src/declarative/qml/qmlcompileddata.cpp index de9bf96..48a0893 100644 --- a/src/declarative/qml/qmlcompileddata.cpp +++ b/src/declarative/qml/qmlcompileddata.cpp @@ -161,8 +161,8 @@ int QmlCompiledData::indexForLocation(const QmlParser::LocationSpan &l) return rv; } -QmlCompiledData::QmlCompiledData() -: importCache(0), root(0), rootPropertyCache(0) +QmlCompiledData::QmlCompiledData(QmlEngine *engine) +: QmlCleanup(engine), importCache(0), root(0), rootPropertyCache(0) { } @@ -189,6 +189,17 @@ QmlCompiledData::~QmlCompiledData() qDeleteAll(cachedClosures); } +void QmlCompiledData::clear() +{ + qDeleteAll(cachedPrograms); + qDeleteAll(cachedClosures); + for (int ii = 0; ii < cachedClosures.count(); ++ii) + cachedClosures[ii] = 0; + for (int ii = 0; ii < cachedPrograms.count(); ++ii) + cachedPrograms[ii] = 0; +} + + QObject *QmlCompiledData::TypeReference::createInstance(QmlContext *ctxt, const QBitField &bindings) const { if (type) { diff --git a/src/declarative/qml/qmlcompiler_p.h b/src/declarative/qml/qmlcompiler_p.h index c0e50e4..732fbad 100644 --- a/src/declarative/qml/qmlcompiler_p.h +++ b/src/declarative/qml/qmlcompiler_p.h @@ -74,10 +74,10 @@ class QmlComponent; class QmlContext; class QScriptProgram; -class Q_AUTOTEST_EXPORT QmlCompiledData : public QmlRefCount +class Q_AUTOTEST_EXPORT QmlCompiledData : public QmlRefCount, public QmlCleanup { public: - QmlCompiledData(); + QmlCompiledData(QmlEngine *engine); virtual ~QmlCompiledData(); QString name; @@ -123,6 +123,10 @@ public: QList urls; void dumpInstructions(); + +protected: + virtual void clear(); // From QmlCleanup + private: void dump(QmlInstruction *, int idx = -1); QmlCompiledData(const QmlCompiledData &other); diff --git a/src/declarative/qml/qmlcompositetypemanager.cpp b/src/declarative/qml/qmlcompositetypemanager.cpp index ff786cf..1613051 100644 --- a/src/declarative/qml/qmlcompositetypemanager.cpp +++ b/src/declarative/qml/qmlcompositetypemanager.cpp @@ -119,7 +119,7 @@ QmlCompositeTypeData::toCompiledComponent(QmlEngine *engine) { if (status == Complete && !compiledComponent) { - compiledComponent = new QmlCompiledData; + compiledComponent = new QmlCompiledData(engine); compiledComponent->url = imports.baseUrl(); compiledComponent->name = compiledComponent->url.toString(); diff --git a/src/declarative/qml/qmldom.cpp b/src/declarative/qml/qmldom.cpp index e46ea96..52530db 100644 --- a/src/declarative/qml/qmldom.cpp +++ b/src/declarative/qml/qmldom.cpp @@ -145,7 +145,7 @@ bool QmlDomDocument::load(QmlEngine *engine, const QByteArray &data, const QUrl d->errors.clear(); d->imports.clear(); - QmlCompiledData *component = new QmlCompiledData; + QmlCompiledData *component = new QmlCompiledData(engine); QmlCompiler compiler; QmlCompositeTypeData *td = ((QmlEnginePrivate *)QmlEnginePrivate::get(engine))->typeManager.getImmediate(data, url); -- cgit v0.12 From 20098f931b6c19f6caf1fc1fc23297d14cb9e707 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Tue, 12 Jan 2010 11:13:55 +1000 Subject: Don't double enter states at startup. QT-2697 --- src/declarative/util/qmlstategroup.cpp | 34 +++++++++++++++------- src/declarative/util/qmlstategroup_p.h | 2 +- .../states/data/autoStateAtStartupRestoreBug.qml | 18 ++++++++++++ tests/auto/declarative/states/tst_states.cpp | 18 ++++++++++++ 4 files changed, 61 insertions(+), 11 deletions(-) create mode 100644 tests/auto/declarative/states/data/autoStateAtStartupRestoreBug.qml diff --git a/src/declarative/util/qmlstategroup.cpp b/src/declarative/util/qmlstategroup.cpp index 373d457..d4db2b9 100644 --- a/src/declarative/util/qmlstategroup.cpp +++ b/src/declarative/util/qmlstategroup.cpp @@ -88,7 +88,7 @@ public: QmlTransition *findTransition(const QString &from, const QString &to); void setCurrentStateInternal(const QString &state, bool = false); - void updateAutoState(); + bool updateAutoState(); }; /*! @@ -231,25 +231,30 @@ void QmlStateGroup::componentComplete() { Q_D(QmlStateGroup); d->componentComplete = true; - d->updateAutoState(); - if (!d->currentState.isEmpty()) { + + if (d->updateAutoState()) { + return; + } else if (!d->currentState.isEmpty()) { QString cs = d->currentState; d->currentState = QString(); d->setCurrentStateInternal(cs, true); } } -void QmlStateGroup::updateAutoState() +/*! + Returns true if the state was changed, otherwise false. +*/ +bool QmlStateGroup::updateAutoState() { Q_D(QmlStateGroup); - d->updateAutoState(); + return d->updateAutoState(); } -void QmlStateGroupPrivate::updateAutoState() +bool QmlStateGroupPrivate::updateAutoState() { Q_Q(QmlStateGroup); if (!componentComplete) - return; + return false; bool revert = false; for (int ii = 0; ii < states.count(); ++ii) { @@ -260,16 +265,25 @@ void QmlStateGroupPrivate::updateAutoState() if (stateChangeDebug()) qWarning() << "Setting auto state due to:" << state->when()->expression(); - q->setState(state->name()); - return; + if (currentState != state->name()) { + q->setState(state->name()); + return true; + } else { + return false; + } } else if (state->name() == currentState) { revert = true; } } } } - if (revert) + if (revert) { + bool rv = currentState != QString(); q->setState(QString()); + return rv; + } else { + return false; + } } QmlTransition *QmlStateGroupPrivate::findTransition(const QString &from, const QString &to) diff --git a/src/declarative/util/qmlstategroup_p.h b/src/declarative/util/qmlstategroup_p.h index 82cc504..112c9eb 100644 --- a/src/declarative/util/qmlstategroup_p.h +++ b/src/declarative/util/qmlstategroup_p.h @@ -82,7 +82,7 @@ Q_SIGNALS: private: friend class QmlState; - void updateAutoState(); + bool updateAutoState(); void removeState(QmlState *state); }; diff --git a/tests/auto/declarative/states/data/autoStateAtStartupRestoreBug.qml b/tests/auto/declarative/states/data/autoStateAtStartupRestoreBug.qml new file mode 100644 index 0000000..693a5c5 --- /dev/null +++ b/tests/auto/declarative/states/data/autoStateAtStartupRestoreBug.qml @@ -0,0 +1,18 @@ +import Qt 4.6 + +Item { + id: root + property int input: 1 + property int test: 9 + + states: [ + State { + name: "portrait" + when: root.input == 1 + PropertyChanges { + target: root + test: 3 + } + } + ] +} diff --git a/tests/auto/declarative/states/tst_states.cpp b/tests/auto/declarative/states/tst_states.cpp index 9d9cf07..3301048 100644 --- a/tests/auto/declarative/states/tst_states.cpp +++ b/tests/auto/declarative/states/tst_states.cpp @@ -70,6 +70,7 @@ private slots: void explicitChanges(); void propertyErrors(); void incorrectRestoreBug(); + void autoStateAtStartupRestoreBug(); void deletingChange(); void deletingState(); void tempState(); @@ -743,6 +744,23 @@ void tst_states::incorrectRestoreBug() QCOMPARE(rect->color(),QColor("green")); } +void tst_states::autoStateAtStartupRestoreBug() +{ + QmlEngine engine; + + QmlComponent component(&engine, SRCDIR "/data/autoStateAtStartupRestoreBug.qml"); + QObject *obj = component.create(); + + QVERIFY(obj != 0); + QCOMPARE(obj->property("test").toInt(), 3); + + obj->setProperty("input", 2); + + QCOMPARE(obj->property("test").toInt(), 9); + + delete obj; +} + void tst_states::deletingChange() { QmlEngine engine; -- cgit v0.12 From ad53d97a1cc91e7b2fed7ed736e20d0b4a58aeaf Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Tue, 12 Jan 2010 11:21:56 +1000 Subject: Compile --- src/script/bridge/qscriptdeclarativeclass_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/script/bridge/qscriptdeclarativeclass_p.h b/src/script/bridge/qscriptdeclarativeclass_p.h index 87ab964..eb94390 100644 --- a/src/script/bridge/qscriptdeclarativeclass_p.h +++ b/src/script/bridge/qscriptdeclarativeclass_p.h @@ -47,7 +47,7 @@ class QScriptContext; class Q_SCRIPT_EXPORT QScriptDeclarativeClass { public: - class Value + class Q_SCRIPT_EXPORT Value { public: Value(); -- cgit v0.12 From 20753bfe4e24fa9883868f351851e7377d9b9f6d Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Tue, 12 Jan 2010 11:37:16 +1000 Subject: Compile --- src/declarative/qml/qmlcleanup.cpp | 4 +++- tests/auto/declarative/qmlinstruction/tst_qmlinstruction.cpp | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/declarative/qml/qmlcleanup.cpp b/src/declarative/qml/qmlcleanup.cpp index 0da6452..599e4e7 100644 --- a/src/declarative/qml/qmlcleanup.cpp +++ b/src/declarative/qml/qmlcleanup.cpp @@ -61,7 +61,9 @@ Create a QmlCleanup for \a engine QmlCleanup::QmlCleanup(QmlEngine *engine) : prev(0), next(0) { - Q_ASSERT(engine); + if (!engine) + return; + QmlEnginePrivate *p = QmlEnginePrivate::get(engine); if (p->cleanup) next = p->cleanup; diff --git a/tests/auto/declarative/qmlinstruction/tst_qmlinstruction.cpp b/tests/auto/declarative/qmlinstruction/tst_qmlinstruction.cpp index 43c64cd..b53942c 100644 --- a/tests/auto/declarative/qmlinstruction/tst_qmlinstruction.cpp +++ b/tests/auto/declarative/qmlinstruction/tst_qmlinstruction.cpp @@ -60,7 +60,7 @@ static void msgHandler(QtMsgType, const char *msg) void tst_qmlinstruction::dump() { - QmlCompiledData *data = new QmlCompiledData; + QmlCompiledData *data = new QmlCompiledData(0); { QmlInstruction i; i.line = 0; -- cgit v0.12 From 57198878ba5300aac4cd9e1481c9b8d2e372a267 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Tue, 12 Jan 2010 11:46:50 +1000 Subject: Always exit on play script failure --- tools/qmlviewer/qfxtester.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/qmlviewer/qfxtester.cpp b/tools/qmlviewer/qfxtester.cpp index 5484771..bd96545 100644 --- a/tools/qmlviewer/qfxtester.cpp +++ b/tools/qmlviewer/qfxtester.cpp @@ -170,7 +170,7 @@ void QmlGraphicsTester::run() testscript = qobject_cast(c.create()); if (testscript) testscript->setParent(this); - else executefailure(); + else { executefailure(); exit(-1); } testscriptidx = 0; } -- cgit v0.12