summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWarwick Allison <warwick.allison@nokia.com>2010-01-12 03:24:36 (GMT)
committerWarwick Allison <warwick.allison@nokia.com>2010-01-12 03:24:36 (GMT)
commitb328136a920ec57ca13db5a39310293c4eaef27c (patch)
treed0f926735992ae75ae6be5bbb5185a2151b72e81
parenta53008073216540bb5cfd40563e4b33ba139832c (diff)
parent57198878ba5300aac4cd9e1481c9b8d2e372a267 (diff)
downloadQt-b328136a920ec57ca13db5a39310293c4eaef27c.zip
Qt-b328136a920ec57ca13db5a39310293c4eaef27c.tar.gz
Qt-b328136a920ec57ca13db5a39310293c4eaef27c.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsgridview.cpp3
-rw-r--r--src/declarative/graphicsitems/qmlgraphicslistview.cpp3
-rw-r--r--src/declarative/graphicsitems/qmlgraphicspathview.cpp3
-rw-r--r--src/declarative/qml/qmlbindingvme.cpp18
-rw-r--r--src/declarative/qml/qmlcleanup.cpp4
-rw-r--r--src/declarative/qml/qmlcompileddata.cpp15
-rw-r--r--src/declarative/qml/qmlcompiler_p.h8
-rw-r--r--src/declarative/qml/qmlcompositetypemanager.cpp2
-rw-r--r--src/declarative/qml/qmldom.cpp2
-rw-r--r--src/declarative/qml/qmltypenamescriptclass.cpp2
-rw-r--r--src/declarative/util/qmlstategroup.cpp34
-rw-r--r--src/declarative/util/qmlstategroup_p.h2
-rw-r--r--src/script/bridge/qscriptdeclarativeclass_p.h2
-rw-r--r--tests/auto/declarative/qmlinstruction/tst_qmlinstruction.cpp2
-rw-r--r--tests/auto/declarative/states/data/autoStateAtStartupRestoreBug.qml18
-rw-r--r--tests/auto/declarative/states/tst_states.cpp18
-rw-r--r--tools/qmlviewer/qfxtester.cpp2
17 files changed, 115 insertions, 23 deletions
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
*/
diff --git a/src/declarative/qml/qmlbindingvme.cpp b/src/declarative/qml/qmlbindingvme.cpp
index 29391a6..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));
@@ -570,7 +583,6 @@ inline static qreal toReal(Register *reg, int type, bool *ok = 0)
if (type == QMetaType::QReal) {
return reg->getqreal();
} else if (type == qMetaTypeId<QVariant>()) {
- *ok = true;
return reg->getvariantptr()->toReal();
} else {
if (ok) *ok = false;
@@ -624,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();
@@ -882,6 +896,8 @@ void QmlBindingVME::run(const char *programData, int instrIndex,
int type = registers[instr->cleanup.reg].gettype();
if (type == qMetaTypeId<QVariant>()) {
((QVariant *)registers[instr->cleanup.reg].typeDataPtr())->~QVariant();
+ } else if (type == QMetaType::QString) {
+ ((QString *)registers[instr->cleanup.reg].typeDataPtr())->~QString();
}
}
break;
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/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<QUrl> 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 29959cb..22f2df3 100644
--- a/src/declarative/qml/qmlcompositetypemanager.cpp
+++ b/src/declarative/qml/qmlcompositetypemanager.cpp
@@ -125,7 +125,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);
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);
}
}
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/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();
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;
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;
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<QmlGraphicsVisualTest *>(c.create());
if (testscript) testscript->setParent(this);
- else executefailure();
+ else { executefailure(); exit(-1); }
testscriptidx = 0;
}