From fa43180a3aab3b7bf2ad2b89b2cc1aed643d7b72 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Mon, 3 Aug 2009 16:27:11 +1000 Subject: Shortcut testing for internal QVariant types --- src/declarative/qml/qmlmetaproperty.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/declarative/qml/qmlmetaproperty.cpp b/src/declarative/qml/qmlmetaproperty.cpp index e6ffd50..5181f12 100644 --- a/src/declarative/qml/qmlmetaproperty.cpp +++ b/src/declarative/qml/qmlmetaproperty.cpp @@ -287,6 +287,8 @@ QmlMetaPropertyPrivate::propertyCategory() const int type = propertyType(); if (type == QmlMetaProperty::Invalid) category = QmlMetaProperty::InvalidProperty; + else if (type < QVariant::UserType) + category = QmlMetaProperty::Normal; else if (type == qMetaTypeId()) category = QmlMetaProperty::Bindable; else if (QmlMetaType::isList(type)) -- cgit v0.12 From dbda9ae7996d090cda296074fc02842f1dd2e0f7 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Tue, 4 Aug 2009 13:09:36 +1000 Subject: Update test --- tests/auto/declarative/qmlbindengine/bindingLoop.txt | 2 ++ .../qmlbindengine/boolPropertiesEvaluateAsBool.1.txt | 2 ++ .../qmlbindengine/boolPropertiesEvaluateAsBool.2.txt | 2 ++ tests/auto/declarative/qmlbindengine/deferredProperties.txt | 2 ++ tests/auto/declarative/qmlbindengine/extensionObjects.txt | 2 ++ .../auto/declarative/qmlbindengine/idShortcutInvalidates.1.txt | 3 +++ tests/auto/declarative/qmlbindengine/idShortcutInvalidates.txt | 3 +++ tests/auto/declarative/qmlbindengine/methods.1.txt | 2 ++ tests/auto/declarative/qmlbindengine/methods.2.txt | 2 ++ tests/auto/declarative/qmlbindengine/signalAssignment.1.txt | 2 ++ tests/auto/declarative/qmlbindengine/signalAssignment.2.txt | 2 ++ tests/auto/declarative/qmlbindengine/testtypes.cpp | 10 +++++----- 12 files changed, 29 insertions(+), 5 deletions(-) diff --git a/tests/auto/declarative/qmlbindengine/bindingLoop.txt b/tests/auto/declarative/qmlbindengine/bindingLoop.txt index e27a76c..8b22dd1 100644 --- a/tests/auto/declarative/qmlbindengine/bindingLoop.txt +++ b/tests/auto/declarative/qmlbindengine/bindingLoop.txt @@ -1,3 +1,5 @@ +import Qt.test 1.0 + MyQmlContainer { children : [ MyQmlObject { diff --git a/tests/auto/declarative/qmlbindengine/boolPropertiesEvaluateAsBool.1.txt b/tests/auto/declarative/qmlbindengine/boolPropertiesEvaluateAsBool.1.txt index 7368ff6..3147f63 100644 --- a/tests/auto/declarative/qmlbindengine/boolPropertiesEvaluateAsBool.1.txt +++ b/tests/auto/declarative/qmlbindengine/boolPropertiesEvaluateAsBool.1.txt @@ -1,3 +1,5 @@ +import Qt.test 1.0 + MyQmlObject { stringProperty: trueProperty?'pass':'fail' } diff --git a/tests/auto/declarative/qmlbindengine/boolPropertiesEvaluateAsBool.2.txt b/tests/auto/declarative/qmlbindengine/boolPropertiesEvaluateAsBool.2.txt index c74493e..c89bb49 100644 --- a/tests/auto/declarative/qmlbindengine/boolPropertiesEvaluateAsBool.2.txt +++ b/tests/auto/declarative/qmlbindengine/boolPropertiesEvaluateAsBool.2.txt @@ -1,3 +1,5 @@ +import Qt.test 1.0 + MyQmlObject { stringProperty: falseProperty?'fail':'pass' } diff --git a/tests/auto/declarative/qmlbindengine/deferredProperties.txt b/tests/auto/declarative/qmlbindengine/deferredProperties.txt index 41aa891..9dabafe 100644 --- a/tests/auto/declarative/qmlbindengine/deferredProperties.txt +++ b/tests/auto/declarative/qmlbindengine/deferredProperties.txt @@ -1,3 +1,5 @@ +import Qt.test 1.0 + MyDeferredObject { value: 10 objectProperty: MyQmlObject {} diff --git a/tests/auto/declarative/qmlbindengine/extensionObjects.txt b/tests/auto/declarative/qmlbindengine/extensionObjects.txt index 4c33de4..a902312 100644 --- a/tests/auto/declarative/qmlbindengine/extensionObjects.txt +++ b/tests/auto/declarative/qmlbindengine/extensionObjects.txt @@ -1,3 +1,5 @@ +import Qt.test 1.0 + MyExtendedObject { baseProperty: baseExtendedProperty diff --git a/tests/auto/declarative/qmlbindengine/idShortcutInvalidates.1.txt b/tests/auto/declarative/qmlbindengine/idShortcutInvalidates.1.txt index 2687465..ccb3a22 100644 --- a/tests/auto/declarative/qmlbindengine/idShortcutInvalidates.1.txt +++ b/tests/auto/declarative/qmlbindengine/idShortcutInvalidates.1.txt @@ -1,3 +1,6 @@ +import Qt.test 1.0 +import Qt 4.6 + MyQmlObject { objectProperty: if(1) OtherObject diff --git a/tests/auto/declarative/qmlbindengine/idShortcutInvalidates.txt b/tests/auto/declarative/qmlbindengine/idShortcutInvalidates.txt index 4aa20ae..6c1fca6 100644 --- a/tests/auto/declarative/qmlbindengine/idShortcutInvalidates.txt +++ b/tests/auto/declarative/qmlbindengine/idShortcutInvalidates.txt @@ -1,3 +1,6 @@ +import Qt.test 1.0 +import Qt 4.6 + MyQmlObject { objectProperty: OtherObject diff --git a/tests/auto/declarative/qmlbindengine/methods.1.txt b/tests/auto/declarative/qmlbindengine/methods.1.txt index 35279e0..8ba300f 100644 --- a/tests/auto/declarative/qmlbindengine/methods.1.txt +++ b/tests/auto/declarative/qmlbindengine/methods.1.txt @@ -1,3 +1,5 @@ +import Qt.test 1.0 + MyQmlObject { id: MyObject onBasicSignal: MyObject.method() diff --git a/tests/auto/declarative/qmlbindengine/methods.2.txt b/tests/auto/declarative/qmlbindengine/methods.2.txt index 352913a..70911f7 100644 --- a/tests/auto/declarative/qmlbindengine/methods.2.txt +++ b/tests/auto/declarative/qmlbindengine/methods.2.txt @@ -1,3 +1,5 @@ +import Qt.test 1.0 + MyQmlObject { id: MyObject onBasicSignal: MyObject.method(163) diff --git a/tests/auto/declarative/qmlbindengine/signalAssignment.1.txt b/tests/auto/declarative/qmlbindengine/signalAssignment.1.txt index ca682fa..fbd0914 100644 --- a/tests/auto/declarative/qmlbindengine/signalAssignment.1.txt +++ b/tests/auto/declarative/qmlbindengine/signalAssignment.1.txt @@ -1,3 +1,5 @@ +import Qt.test 1.0 + MyQmlObject { onBasicSignal: setString('pass') } diff --git a/tests/auto/declarative/qmlbindengine/signalAssignment.2.txt b/tests/auto/declarative/qmlbindengine/signalAssignment.2.txt index 5efd583..8addcb9 100644 --- a/tests/auto/declarative/qmlbindengine/signalAssignment.2.txt +++ b/tests/auto/declarative/qmlbindengine/signalAssignment.2.txt @@ -1,3 +1,5 @@ +import Qt.test 1.0 + MyQmlObject { onArgumentSignal: setString('pass ' + a + ' ' + b + ' ' + c) } diff --git a/tests/auto/declarative/qmlbindengine/testtypes.cpp b/tests/auto/declarative/qmlbindengine/testtypes.cpp index 2f83f58..6122186 100644 --- a/tests/auto/declarative/qmlbindengine/testtypes.cpp +++ b/tests/auto/declarative/qmlbindengine/testtypes.cpp @@ -32,10 +32,10 @@ private: int m_value; }; -QML_DEFINE_TYPE(MyQmlObject,MyQmlObject); -QML_DEFINE_TYPE(MyDeferredObject,MyDeferredObject); -QML_DEFINE_TYPE(MyQmlContainer,MyQmlContainer); -QML_DEFINE_EXTENDED_TYPE(MyBaseExtendedObject,MyBaseExtendedObject,BaseExtensionObject); -QML_DEFINE_EXTENDED_TYPE(MyExtendedObject,MyExtendedObject,ExtensionObject); +QML_DEFINE_TYPE(Qt/test, 1, 0, 0, MyQmlObject,MyQmlObject); +QML_DEFINE_TYPE(Qt/test, 1, 0, 0, MyDeferredObject,MyDeferredObject); +QML_DEFINE_TYPE(Qt/test, 1, 0, 0, MyQmlContainer,MyQmlContainer); +QML_DEFINE_EXTENDED_TYPE(Qt/test, 1, 0, 0, MyBaseExtendedObject,MyBaseExtendedObject,BaseExtensionObject); +QML_DEFINE_EXTENDED_TYPE(Qt/test, 1, 0, 0, MyExtendedObject,MyExtendedObject,ExtensionObject); #include "testtypes.moc" -- cgit v0.12 From 588093b3e12dd5039bcc4ee545d9d9112d25394f Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Tue, 4 Aug 2009 13:18:37 +1000 Subject: Improve performance by separating id and context properties --- src/declarative/qml/qmlbasicscript.cpp | 2 +- src/declarative/qml/qmlcompiler.cpp | 6 +- src/declarative/qml/qmlcontext.cpp | 68 +++++++++++----------- src/declarative/qml/qmlcontext.h | 3 - src/declarative/qml/qmlcontext_p.h | 18 +++++- src/declarative/qml/qmlengine.cpp | 62 +++++--------------- src/declarative/qml/qmlinstruction_p.h | 2 + src/declarative/qml/qmlvme.cpp | 8 ++- .../qmlbindengine/tst_qmlbindengine.cpp | 5 -- .../declarative/qmlcomponent/object_id.txt | 6 ++ .../declarative/qmlcomponent/tst_qmlcomponent.cpp | 4 ++ 11 files changed, 88 insertions(+), 96 deletions(-) create mode 100644 tests/benchmarks/declarative/qmlcomponent/object_id.txt diff --git a/src/declarative/qml/qmlbasicscript.cpp b/src/declarative/qml/qmlbasicscript.cpp index b940d61..ca137c7 100644 --- a/src/declarative/qml/qmlbasicscript.cpp +++ b/src/declarative/qml/qmlbasicscript.cpp @@ -668,7 +668,7 @@ QVariant QmlBasicScript::run(QmlContext *context, void *voidCache, CacheState *c switch(instr.type) { case ScriptInstruction::LoadIdObject: { - stack.push(contextPrivate->propertyValues.at(instr.fetch.idx)); + stack.push(QVariant::fromValue(contextPrivate->idValues[instr.fetch.idx].data())); enginePrivate->capturedProperties << QmlEnginePrivate::CapturedProperty(context, -1, contextPrivate->notifyIndex + instr.fetch.idx); state = Reset; diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp index 091b7bb..197bd44 100644 --- a/src/declarative/qml/qmlcompiler.cpp +++ b/src/declarative/qml/qmlcompiler.cpp @@ -603,6 +603,7 @@ void QmlCompiler::compileTree(Object *tree) init.line = 0; init.init.bindingsSize = compileState.bindings.count(); init.init.parserStatusSize = compileState.parserStatusCount; + init.init.idSize = compileState.ids.count(); output->bytecode << init; genObject(tree); @@ -774,6 +775,7 @@ void QmlCompiler::genObject(QmlParser::Object *obj) id.type = QmlInstruction::SetId; id.line = -1; id.setId.value = output->indexForString(obj->id); + id.setId.index = obj->idIndex; output->bytecode << id; } @@ -917,6 +919,7 @@ void QmlCompiler::genComponent(QmlParser::Object *obj) init.type = QmlInstruction::Init; init.init.bindingsSize = compileState.bindings.count(); init.init.parserStatusSize = compileState.parserStatusCount; + init.init.idSize = compileState.ids.count(); init.line = obj->location.start.line; output->bytecode << init; @@ -936,7 +939,8 @@ void QmlCompiler::genComponent(QmlParser::Object *obj) QmlInstruction id; id.type = QmlInstruction::SetId; id.line = -1; - id.setId.value = output->indexForString(obj->id);; + id.setId.value = output->indexForString(obj->id); + id.setId.index = obj->idIndex; output->bytecode << id; } } diff --git a/src/declarative/qml/qmlcontext.cpp b/src/declarative/qml/qmlcontext.cpp index f347cf3..fd64a95 100644 --- a/src/declarative/qml/qmlcontext.cpp +++ b/src/declarative/qml/qmlcontext.cpp @@ -55,7 +55,8 @@ QT_BEGIN_NAMESPACE QmlContextPrivate::QmlContextPrivate() : parent(0), engine(0), isInternal(false), notifyIndex(-1), - highPriorityCount(0), startLine(-1), endLine(-1) + highPriorityCount(0), startLine(-1), endLine(-1), idValues(0), + idValueCount(0) { } @@ -71,29 +72,21 @@ void QmlContextPrivate::dump(int depth) parent->d_func()->dump(depth + 1); } -void QmlContextPrivate::destroyed(QObject *obj) +void QmlContextPrivate::destroyed(ContextGuard *guard) { Q_Q(QmlContext); - defaultObjects.removeAll(obj); - - QVariant variantObject = QVariant::fromValue(obj); - QVarLengthArray notifies; - for (int ii = 0; ii < propertyValues.count(); ++ii) { - if (propertyValues.at(ii) == variantObject) { - propertyValues[ii] = QVariant(); - notifies.append(ii); - } - } - - // There is no need to emit these notifications if our parent is in the // process of being deleted (which is *probably* why obj has been destroyed // anyway), as we're about to get deleted which will invalidate all the // expressions that could depend on us QObject *parent = q->parent(); - if (!parent || !QObjectPrivate::get(parent)->wasDeleted) { - for (int ii = 0; ii < notifies.count(); ++ii) { - QMetaObject::activate(q, notifies[ii] + notifyIndex, 0); + if (parent && QObjectPrivate::get(parent)->wasDeleted) + return; + + for (int ii = 0; ii < idValueCount; ++ii) { + if (&idValues[ii] == guard) { + QMetaObject::activate(q, ii + notifyIndex, 0); + return; } } } @@ -131,8 +124,6 @@ void QmlContextPrivate::addDefaultObject(QObject *object, Priority priority) } else { defaultObjects.append(object); } - QObject::connect(object, SIGNAL(destroyed(QObject*)), - q_ptr, SLOT(objectDestroyed(QObject*))); } @@ -306,6 +297,8 @@ QmlContext::~QmlContext() } } d->contextObjects.clear(); + + delete [] d->idValues; } void QmlContextPrivate::invalidateEngines() @@ -365,7 +358,7 @@ void QmlContext::setContextProperty(const QString &name, const QVariant &value) } else { QHash::ConstIterator iter = d->propertyNames.find(name); if(iter == d->propertyNames.end()) { - d->propertyNames.insert(name, d->propertyValues.count()); + d->propertyNames.insert(name, d->idValueCount + d->propertyValues.count()); d->propertyValues.append(value); } else { d->propertyValues[*iter] = value; @@ -374,6 +367,25 @@ void QmlContext::setContextProperty(const QString &name, const QVariant &value) } } +void QmlContextPrivate::setIdProperty(const QString &name, int idx, + QObject *obj) +{ + if (notifyIndex == -1) { + Q_Q(QmlContext); + notifyIndex = q->metaObject()->methodCount(); + } + + propertyNames.insert(name, idx); + idValues[idx].priv = this; + idValues[idx] = obj; +} + +void QmlContextPrivate::setIdPropertyCount(int count) +{ + idValues = new ContextGuard[count]; + idValueCount = count; +} + /*! Set a the \a value of the \a name property on this context. @@ -385,20 +397,12 @@ void QmlContext::setContextProperty(const QString &name, QObject *value) if (d->notifyIndex == -1) d->notifyIndex = this->metaObject()->methodCount(); - QObject::connect(value, SIGNAL(destroyed(QObject*)), - this, SLOT(objectDestroyed(QObject*))); - QHash::ConstIterator iter = d->propertyNames.find(name); if(iter == d->propertyNames.end()) { - d->propertyNames.insert(name, d->propertyValues.count()); + d->propertyNames.insert(name, d->idValueCount + d->propertyValues.count()); d->propertyValues.append(QVariant::fromValue(value)); } else { int idx = *iter; - if (QmlMetaType::isObject(d->propertyValues.at(idx).userType())) { - QObject *old = QmlMetaType::toQObject(d->propertyValues.at(idx)); - QObject::disconnect(old, SIGNAL(destroyed(QObject*)), - this, SLOT(objectDestroyed(QObject*))); - } d->propertyValues[*iter] = QVariant::fromValue(value); QMetaObject::activate(this, *iter + d->notifyIndex, 0); } @@ -445,10 +449,4 @@ void QmlContext::setBaseUrl(const QUrl &baseUrl) d_func()->url = baseUrl; } -void QmlContext::objectDestroyed(QObject *object) -{ - Q_D(QmlContext); - d->destroyed(object); -} - QT_END_NAMESPACE diff --git a/src/declarative/qml/qmlcontext.h b/src/declarative/qml/qmlcontext.h index 877ff0f..1f29ca2 100644 --- a/src/declarative/qml/qmlcontext.h +++ b/src/declarative/qml/qmlcontext.h @@ -77,9 +77,6 @@ public: void setBaseUrl(const QUrl &); -private Q_SLOTS: - void objectDestroyed(QObject *); - private: friend class QmlVME; friend class QmlEngine; diff --git a/src/declarative/qml/qmlcontext_p.h b/src/declarative/qml/qmlcontext_p.h index fc615b6..5bb3aaf 100644 --- a/src/declarative/qml/qmlcontext_p.h +++ b/src/declarative/qml/qmlcontext_p.h @@ -59,6 +59,7 @@ #include #include #include +#include QT_BEGIN_NAMESPACE @@ -96,8 +97,6 @@ public: void dump(); void dump(int depth); - void destroyed(QObject *); - enum Priority { HighPriority, NormalPriority @@ -111,6 +110,21 @@ public: QmlSimpleDeclarativeData contextData; QObjectList contextObjects; + + struct ContextGuard : public QGuard + { + QmlContextPrivate *priv; + ContextGuard &operator=(QObject *obj) { + (QGuard&)*this = obj; return *this; + } + void objectDestroyed(QObject *o) { priv->destroyed(this); } + }; + ContextGuard *idValues; + int idValueCount; + void setIdProperty(const QString &, int, QObject *); + void setIdPropertyCount(int); + void destroyed(ContextGuard *); + // Only used for debugging QList > instances; }; diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp index f6d70e0..68ad655 100644 --- a/src/declarative/qml/qmlengine.cpp +++ b/src/declarative/qml/qmlengine.cpp @@ -747,10 +747,6 @@ QmlContextScriptClass::queryProperty(const QScriptValue &object, QString propName = name.toString(); -#ifdef PROPERTY_DEBUG - qWarning() << "Query Context:" << propName << bindContext; -#endif - *id = InvalidId; if (bindContext->d_func()->propertyNames.contains(propName)) { rv |= HandlesReadAccess; @@ -767,17 +763,12 @@ QmlContextScriptClass::queryProperty(const QScriptValue &object, } QScriptValue QmlContextScriptClass::property(const QScriptValue &object, - const QScriptString &name, - uint id) + const QScriptString &name, + uint id) { QmlContext *bindContext = static_cast(object.data().toQObject()); -#ifdef PROPERTY_DEBUG - QString propName = name.toString(); - qWarning() << "Context Property:" << propName << bindContext; -#endif - uint basicId = id & QmlScriptClass::ClassIdMask; QScriptEngine *scriptEngine = QmlEnginePrivate::getScriptEngine(engine); @@ -786,18 +777,20 @@ QScriptValue QmlContextScriptClass::property(const QScriptValue &object, switch (basicId) { case VariantPropertyId: { + QmlContextPrivate *contextPrivate = bindContext->d_func(); QString propName = name.toString(); - int index = bindContext->d_func()->propertyNames.value(propName); - QVariant value = bindContext->d_func()->propertyValues.at(index); -#ifdef PROPERTY_DEBUG - qWarning() << "Context Property: Resolved property" << propName - << "to context variant property list" << bindContext <<". Value:" << rv.toVariant(); -#endif + int index = contextPrivate->propertyNames.value(propName); + QScriptValue rv; - if (QmlMetaType::isObject(value.userType())) { - rv = scriptEngine->newObject(ep->objectClass, scriptEngine->newVariant(value)); + if (index < contextPrivate->idValueCount) { + rv = scriptEngine->newObject(ep->objectClass, scriptEngine->newVariant(QVariant::fromValue(contextPrivate->idValues[index].data()))); } else { - rv = scriptEngine->newVariant(value); + QVariant value = contextPrivate->propertyValues.at(index); + if (QmlMetaType::isObject(value.userType())) { + rv = scriptEngine->newObject(ep->objectClass, scriptEngine->newVariant(value)); + } else { + rv = scriptEngine->newVariant(value); + } } ep->capturedProperties << QmlEnginePrivate::CapturedProperty(bindContext, -1, index + bindContext->d_func()->notifyIndex); return rv; @@ -809,10 +802,6 @@ QScriptValue QmlContextScriptClass::property(const QScriptValue &object, QScriptValue rv = ep->propertyObject(name, obj, id & ~QmlScriptClass::ClassIdSelectorMask); if (rv.isValid()) { -#ifdef PROPERTY_DEBUG - qWarning() << "~Property: Resolved property" << propName - << "to context default object" << bindContext << obj <<". Value:" << rv.toVariant(); -#endif return rv; } break; @@ -832,10 +821,6 @@ void QmlContextScriptClass::setProperty(QScriptValue &object, QmlContext *bindContext = static_cast(object.data().toQObject()); -#ifdef PROPERTY_DEBUG - QString propName = name.toString(); - qWarning() << "Set QmlObject Property" << name.toString() << value.toVariant(); -#endif int objIdx = (id & QmlScriptClass::ClassIdSelectorMask) >> 24; QObject *obj = bindContext->d_func()->defaultObjects.at(objIdx); @@ -975,10 +960,6 @@ QScriptClass::QueryFlags QmlObjectScriptClass::queryProperty(const QScriptValue QueryFlags rv = 0; QString propName = name.toString(); -#ifdef PROPERTY_DEBUG - qWarning() << "Query QmlObject:" << propName << obj; -#endif - if (obj) rv = QmlEnginePrivate::get(engine)->queryObject(propName, id, obj); @@ -991,20 +972,10 @@ QScriptValue QmlObjectScriptClass::property(const QScriptValue &object, { QObject *obj = object.data().toQObject(); -#ifdef PROPERTY_DEBUG - QString propName = name.toString(); - qWarning() << "QmlObject Property:" << propName << obj; -#endif - QScriptValue rv = QmlEnginePrivate::get(engine)->propertyObject(name, obj, id); - if (rv.isValid()) { -#ifdef PROPERTY_DEBUG - qWarning() << "~Property: Resolved property" << propName - << "to object" << obj <<". Value:" << rv.toVariant(); -#endif + if (rv.isValid()) return rv; - } return QScriptValue(); } @@ -1018,11 +989,6 @@ void QmlObjectScriptClass::setProperty(QScriptValue &object, QObject *obj = object.data().toQObject(); -#ifdef PROPERTY_DEBUG - QString propName = name.toString(); - qWarning() << "Set QmlObject Property" << name.toString() << value.toVariant(); -#endif - QScriptEngine *scriptEngine = QmlEnginePrivate::getScriptEngine(engine); QScriptValue oldact = scriptEngine->currentContext()->activationObject(); scriptEngine->currentContext()->setActivationObject(scriptEngine->globalObject()); diff --git a/src/declarative/qml/qmlinstruction_p.h b/src/declarative/qml/qmlinstruction_p.h index d4fe68c..c3d676f 100644 --- a/src/declarative/qml/qmlinstruction_p.h +++ b/src/declarative/qml/qmlinstruction_p.h @@ -163,6 +163,7 @@ public: struct { int bindingsSize; int parserStatusSize; + int idSize; } init; struct { int type; @@ -175,6 +176,7 @@ public: } storeMeta; struct { int value; + int index; } setId; struct { int property; diff --git a/src/declarative/qml/qmlvme.cpp b/src/declarative/qml/qmlvme.cpp index ee41fe4..7c02548 100644 --- a/src/declarative/qml/qmlvme.cpp +++ b/src/declarative/qml/qmlvme.cpp @@ -64,6 +64,7 @@ #include #include #include +#include QT_BEGIN_NAMESPACE @@ -144,6 +145,7 @@ QObject *QmlVME::run(QStack &stack, QmlContext *ctxt, QmlCompiledData vmeErrors.clear(); QmlEnginePrivate *ep = QmlEnginePrivate::get(ctxt->engine()); + QmlContextPrivate *cp = (QmlContextPrivate *)QObjectPrivate::get(ctxt); for (int ii = start; !isError() && ii < (start + count); ++ii) { QmlInstruction &instr = comp->bytecode[ii]; @@ -155,6 +157,9 @@ QObject *QmlVME::run(QStack &stack, QmlContext *ctxt, QmlCompiledData bindValues = QmlEnginePrivate::SimpleList(instr.init.bindingsSize); if (instr.init.parserStatusSize) parserStatus = QmlEnginePrivate::SimpleList(instr.init.parserStatusSize); + + if (instr.init.idSize) + cp->setIdPropertyCount(instr.init.idSize); } break; @@ -194,7 +199,8 @@ QObject *QmlVME::run(QStack &stack, QmlContext *ctxt, QmlCompiledData case QmlInstruction::SetId: { QObject *target = stack.top(); - ctxt->setContextProperty(primitives.at(instr.setId.value), target); +// ctxt->setContextProperty(primitives.at(instr.setId.value), target); + cp->setIdProperty(primitives.at(instr.setId.value), instr.setId.index, target); } break; diff --git a/tests/auto/declarative/qmlbindengine/tst_qmlbindengine.cpp b/tests/auto/declarative/qmlbindengine/tst_qmlbindengine.cpp index 8d3c0b4..01cb54b 100644 --- a/tests/auto/declarative/qmlbindengine/tst_qmlbindengine.cpp +++ b/tests/auto/declarative/qmlbindengine/tst_qmlbindengine.cpp @@ -276,11 +276,6 @@ void tst_qmlbindengine::contextPropertiesTriggerReeval() MyExpression expr(&context, "testObj2"); QCOMPARE(expr.changed, false); QCOMPARE(expr.value(), QVariant::fromValue((QObject *)object3)); - - delete object3; - - QCOMPARE(expr.changed, true); - QCOMPARE(expr.value(), QVariant()); } } diff --git a/tests/benchmarks/declarative/qmlcomponent/object_id.txt b/tests/benchmarks/declarative/qmlcomponent/object_id.txt new file mode 100644 index 0000000..526b6ad --- /dev/null +++ b/tests/benchmarks/declarative/qmlcomponent/object_id.txt @@ -0,0 +1,6 @@ +import Qt 4.6 + +Object { + id: Blah +} + diff --git a/tests/benchmarks/declarative/qmlcomponent/tst_qmlcomponent.cpp b/tests/benchmarks/declarative/qmlcomponent/tst_qmlcomponent.cpp index f032004..f0e029d 100644 --- a/tests/benchmarks/declarative/qmlcomponent/tst_qmlcomponent.cpp +++ b/tests/benchmarks/declarative/qmlcomponent/tst_qmlcomponent.cpp @@ -56,6 +56,7 @@ void tst_qmlcomponent::creation_data() QTest::addColumn("file"); QTest::newRow("Object") << "object.txt"; + QTest::newRow("Object - Id") << "object_id.txt"; QTest::newRow("MyQmlObject") << "myqmlobject.txt"; QTest::newRow("MyQmlObject: basic binding") << "myqmlobject_binding.txt"; QTest::newRow("Synthesized properties") << "synthesized_properties.txt"; @@ -70,6 +71,9 @@ void tst_qmlcomponent::creation() QmlComponent c(&engine, file); QVERIFY(c.isReady()); + QObject *obj = c.create(); + delete obj; + QBENCHMARK { QObject *obj = c.create(); delete obj; -- cgit v0.12 From 826e1f392908b497fa254513b348614376b892a2 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Tue, 4 Aug 2009 14:54:43 +1000 Subject: Remove unused QmlContextPrivate member variables --- src/declarative/qml/qmlcompileddata.cpp | 7 +------ src/declarative/qml/qmlcomponent.cpp | 5 ----- src/declarative/qml/qmlcontext.cpp | 3 +-- src/declarative/qml/qmlcontext_p.h | 4 ---- 4 files changed, 2 insertions(+), 17 deletions(-) diff --git a/src/declarative/qml/qmlcompileddata.cpp b/src/declarative/qml/qmlcompileddata.cpp index 0563891..ffb89b3 100644 --- a/src/declarative/qml/qmlcompileddata.cpp +++ b/src/declarative/qml/qmlcompileddata.cpp @@ -170,12 +170,7 @@ QObject *QmlCompiledData::TypeReference::createInstance(QmlContext *ctxt) const return rv; } else { Q_ASSERT(component); - QObject *rv = component->create(ctxt); - QmlContext *ctxt = qmlContext(rv); - if(ctxt) { - static_cast(QObjectPrivate::get(ctxt))->typeName = className; - } - return rv; + return component->create(ctxt); } } diff --git a/src/declarative/qml/qmlcomponent.cpp b/src/declarative/qml/qmlcomponent.cpp index 8fb7736..d4e383d 100644 --- a/src/declarative/qml/qmlcomponent.cpp +++ b/src/declarative/qml/qmlcomponent.cpp @@ -488,11 +488,6 @@ QObject *QmlComponent::beginCreate(QmlContext *context) static_cast(QObjectPrivate::get(context)); QmlContext *ctxt = new QmlContext(context, 0, true); static_cast(ctxt->d_ptr)->url = d->cc->url; - if(d->start != -1) { - // ### FIXME - static_cast(ctxt->d_ptr)->startLine = d->cc->bytecode.at(d->start - 1).line; - static_cast(ctxt->d_ptr)->endLine = d->cc->bytecode.at(d->start - 1).createComponent.endLine; - } QmlVME vme; QObject *rv = vme.run(ctxt, d->cc, d->start, d->count); diff --git a/src/declarative/qml/qmlcontext.cpp b/src/declarative/qml/qmlcontext.cpp index fd64a95..365ad6d 100644 --- a/src/declarative/qml/qmlcontext.cpp +++ b/src/declarative/qml/qmlcontext.cpp @@ -55,8 +55,7 @@ QT_BEGIN_NAMESPACE QmlContextPrivate::QmlContextPrivate() : parent(0), engine(0), isInternal(false), notifyIndex(-1), - highPriorityCount(0), startLine(-1), endLine(-1), idValues(0), - idValueCount(0) + highPriorityCount(0), idValues(0), idValueCount(0) { } diff --git a/src/declarative/qml/qmlcontext_p.h b/src/declarative/qml/qmlcontext_p.h index 5bb3aaf..4240c8a 100644 --- a/src/declarative/qml/qmlcontext_p.h +++ b/src/declarative/qml/qmlcontext_p.h @@ -88,9 +88,6 @@ public: QScriptValueList scopeChain; QUrl url; - QByteArray typeName; - int startLine; - int endLine; void init(); @@ -110,7 +107,6 @@ public: QmlSimpleDeclarativeData contextData; QObjectList contextObjects; - struct ContextGuard : public QGuard { QmlContextPrivate *priv; -- cgit v0.12 From 7950ccd27ea1353c699dc77242a03bd347daa5e5 Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Wed, 5 Aug 2009 08:41:15 +1000 Subject: Move QmlFontFamily to extra. --- src/declarative/extra/extra.pri | 6 +- src/declarative/extra/qmlfontfamily.cpp | 206 ++++++++++++++++++++++++++++++++ src/declarative/extra/qmlfontfamily.h | 94 +++++++++++++++ src/declarative/util/qmlfontfamily.cpp | 206 -------------------------------- src/declarative/util/qmlfontfamily.h | 94 --------------- src/declarative/util/util.pri | 2 - 6 files changed, 304 insertions(+), 304 deletions(-) create mode 100644 src/declarative/extra/qmlfontfamily.cpp create mode 100644 src/declarative/extra/qmlfontfamily.h delete mode 100644 src/declarative/util/qmlfontfamily.cpp delete mode 100644 src/declarative/util/qmlfontfamily.h diff --git a/src/declarative/extra/extra.pri b/src/declarative/extra/extra.pri index d3ce7eb..c731afa 100644 --- a/src/declarative/extra/extra.pri +++ b/src/declarative/extra/extra.pri @@ -8,7 +8,8 @@ SOURCES += \ extra/qfxflowview.cpp \ extra/qfxparticles.cpp \ extra/qmlbehaviour.cpp \ - extra/qbindablemap.cpp + extra/qbindablemap.cpp \ + extra/qmlfontfamily.cpp HEADERS += \ extra/qnumberformat.h \ @@ -21,7 +22,8 @@ HEADERS += \ extra/qfxflowview.h \ extra/qfxparticles.h \ extra/qmlbehaviour.h \ - extra/qbindablemap.h + extra/qbindablemap.h \ + extra/qmlfontfamily.h contains(QT_CONFIG, xmlpatterns) { QT+=xmlpatterns diff --git a/src/declarative/extra/qmlfontfamily.cpp b/src/declarative/extra/qmlfontfamily.cpp new file mode 100644 index 0000000..73688c1 --- /dev/null +++ b/src/declarative/extra/qmlfontfamily.cpp @@ -0,0 +1,206 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "private/qobject_p.h" +#include "qmlfontfamily.h" +#include +#include +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class QmlFontFamilyPrivate : public QObjectPrivate +{ + Q_DECLARE_PUBLIC(QmlFontFamily); + +public: + QmlFontFamilyPrivate() : reply(0), status(QmlFontFamily::Null) {} + + void addFontToDatabase(const QByteArray &); + + QUrl url; + QString name; + QNetworkReply *reply; + QmlFontFamily::Status status; +}; + +QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,FontFamily,QmlFontFamily) + +/*! + \qmlclass FontFamily QmlFontFamily + \ingroup group_utility + \brief This item allows using fonts by name or url. + + Example: + \code + FontFamily { id: FixedFont; name: "Courier" } + FontFamily { id: WebFont; source: "http://www.mysite.com/myfont.ttf" } + + Text { text: "Fixed-size font"; font.family: FixedFont.name } + Text { text: "Fancy font"; font.family: WebFont.name } + \endcode +*/ +QmlFontFamily::QmlFontFamily(QObject *parent) + : QObject(*(new QmlFontFamilyPrivate), parent) +{ +} + +QmlFontFamily::~QmlFontFamily() +{ +} + +/*! + \qmlproperty url FontFamily::source + The url of the font to load. +*/ +QUrl QmlFontFamily::source() const +{ + Q_D(const QmlFontFamily); + return d->url; +} + +void QmlFontFamily::setSource(const QUrl &url) +{ + Q_D(QmlFontFamily); + if (url == d->url) + return; + d->url = qmlContext(this)->resolvedUrl(url); + + d->status = Loading; + emit statusChanged(); +#ifndef QT_NO_LOCALFILE_OPTIMIZED_QML + if (d->url.scheme() == QLatin1String("file")) { + QFile file(d->url.toLocalFile()); + file.open(QIODevice::ReadOnly); + QByteArray ba = file.readAll(); + d->addFontToDatabase(ba); + } else +#endif + { + QNetworkRequest req(d->url); + req.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache); + d->reply = qmlEngine(this)->networkAccessManager()->get(req); + QObject::connect(d->reply, SIGNAL(finished()), this, SLOT(replyFinished())); + } +} + +/*! + \qmlproperty string FontFamily::name + + This property holds the name of the font family. + It is set automatically when a font is loaded using the \c url property. + + Use this to set the \c font.family property of a \c Text item. + + Example: + \qml + FontFamily { id: WebFont; source: "http://www.mysite.com/myfont.ttf" } + Text { text: "Fancy font"; font.family: WebFont.name } + \endqml +*/ +QString QmlFontFamily::name() const +{ + Q_D(const QmlFontFamily); + return d->name; +} + +void QmlFontFamily::setName(const QString &name) +{ + Q_D(QmlFontFamily); + if (d->name == name ) + return; + d->name = name; + emit nameChanged(); +} + +/*! + \qmlproperty enum FontFamily::status + + This property holds the status of font loading. It can be one of: + \list + \o Null - no font has been set + \o Ready - the font has been loaded + \o Loading - the font is currently being loaded + \o Error - an error occurred while loading the font + \endlist +*/ +QmlFontFamily::Status QmlFontFamily::status() const +{ + Q_D(const QmlFontFamily); + return d->status; +} + +void QmlFontFamily::replyFinished() +{ + Q_D(QmlFontFamily); + if (!d->reply->error()) { + QByteArray ba = d->reply->readAll(); + d->addFontToDatabase(ba); + } else { + d->status = Error; + emit statusChanged(); + } + d->reply->deleteLater(); + d->reply = 0; +} + +void QmlFontFamilyPrivate::addFontToDatabase(const QByteArray &ba) +{ + Q_Q(QmlFontFamily); + + int id = QFontDatabase::addApplicationFontFromData(ba); + if (id != -1) { + name = QFontDatabase::applicationFontFamilies(id).at(0); + emit q->nameChanged(); + status = QmlFontFamily::Ready; + } else { + status = QmlFontFamily::Error; + qWarning() << "Cannot load font: " << name << url; + } + emit q->statusChanged(); +} + +QT_END_NAMESPACE diff --git a/src/declarative/extra/qmlfontfamily.h b/src/declarative/extra/qmlfontfamily.h new file mode 100644 index 0000000..17b6635 --- /dev/null +++ b/src/declarative/extra/qmlfontfamily.h @@ -0,0 +1,94 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMLFONTFAMILY_H +#define QMLFONTFAMILY_H + +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) + +class QmlFontFamilyPrivate; +class Q_DECLARATIVE_EXPORT QmlFontFamily : public QObject +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QmlFontFamily) + Q_ENUMS(Status) + + Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged) + Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) + Q_PROPERTY(Status status READ status NOTIFY statusChanged) + +public: + enum Status { Null = 0, Ready, Loading, Error }; + + QmlFontFamily(QObject *parent = 0); + ~QmlFontFamily(); + + QUrl source() const; + void setSource(const QUrl &url); + + QString name() const; + void setName(const QString &name); + + Status status() const; + +private Q_SLOTS: + void replyFinished(); + +Q_SIGNALS: + void nameChanged(); + void statusChanged(); +}; + +QT_END_NAMESPACE + +QML_DECLARE_TYPE(QmlFontFamily) + +QT_END_HEADER + +#endif // QMLFONTFAMILY_H + diff --git a/src/declarative/util/qmlfontfamily.cpp b/src/declarative/util/qmlfontfamily.cpp deleted file mode 100644 index 73688c1..0000000 --- a/src/declarative/util/qmlfontfamily.cpp +++ /dev/null @@ -1,206 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "private/qobject_p.h" -#include "qmlfontfamily.h" -#include -#include -#include -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class QmlFontFamilyPrivate : public QObjectPrivate -{ - Q_DECLARE_PUBLIC(QmlFontFamily); - -public: - QmlFontFamilyPrivate() : reply(0), status(QmlFontFamily::Null) {} - - void addFontToDatabase(const QByteArray &); - - QUrl url; - QString name; - QNetworkReply *reply; - QmlFontFamily::Status status; -}; - -QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,FontFamily,QmlFontFamily) - -/*! - \qmlclass FontFamily QmlFontFamily - \ingroup group_utility - \brief This item allows using fonts by name or url. - - Example: - \code - FontFamily { id: FixedFont; name: "Courier" } - FontFamily { id: WebFont; source: "http://www.mysite.com/myfont.ttf" } - - Text { text: "Fixed-size font"; font.family: FixedFont.name } - Text { text: "Fancy font"; font.family: WebFont.name } - \endcode -*/ -QmlFontFamily::QmlFontFamily(QObject *parent) - : QObject(*(new QmlFontFamilyPrivate), parent) -{ -} - -QmlFontFamily::~QmlFontFamily() -{ -} - -/*! - \qmlproperty url FontFamily::source - The url of the font to load. -*/ -QUrl QmlFontFamily::source() const -{ - Q_D(const QmlFontFamily); - return d->url; -} - -void QmlFontFamily::setSource(const QUrl &url) -{ - Q_D(QmlFontFamily); - if (url == d->url) - return; - d->url = qmlContext(this)->resolvedUrl(url); - - d->status = Loading; - emit statusChanged(); -#ifndef QT_NO_LOCALFILE_OPTIMIZED_QML - if (d->url.scheme() == QLatin1String("file")) { - QFile file(d->url.toLocalFile()); - file.open(QIODevice::ReadOnly); - QByteArray ba = file.readAll(); - d->addFontToDatabase(ba); - } else -#endif - { - QNetworkRequest req(d->url); - req.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache); - d->reply = qmlEngine(this)->networkAccessManager()->get(req); - QObject::connect(d->reply, SIGNAL(finished()), this, SLOT(replyFinished())); - } -} - -/*! - \qmlproperty string FontFamily::name - - This property holds the name of the font family. - It is set automatically when a font is loaded using the \c url property. - - Use this to set the \c font.family property of a \c Text item. - - Example: - \qml - FontFamily { id: WebFont; source: "http://www.mysite.com/myfont.ttf" } - Text { text: "Fancy font"; font.family: WebFont.name } - \endqml -*/ -QString QmlFontFamily::name() const -{ - Q_D(const QmlFontFamily); - return d->name; -} - -void QmlFontFamily::setName(const QString &name) -{ - Q_D(QmlFontFamily); - if (d->name == name ) - return; - d->name = name; - emit nameChanged(); -} - -/*! - \qmlproperty enum FontFamily::status - - This property holds the status of font loading. It can be one of: - \list - \o Null - no font has been set - \o Ready - the font has been loaded - \o Loading - the font is currently being loaded - \o Error - an error occurred while loading the font - \endlist -*/ -QmlFontFamily::Status QmlFontFamily::status() const -{ - Q_D(const QmlFontFamily); - return d->status; -} - -void QmlFontFamily::replyFinished() -{ - Q_D(QmlFontFamily); - if (!d->reply->error()) { - QByteArray ba = d->reply->readAll(); - d->addFontToDatabase(ba); - } else { - d->status = Error; - emit statusChanged(); - } - d->reply->deleteLater(); - d->reply = 0; -} - -void QmlFontFamilyPrivate::addFontToDatabase(const QByteArray &ba) -{ - Q_Q(QmlFontFamily); - - int id = QFontDatabase::addApplicationFontFromData(ba); - if (id != -1) { - name = QFontDatabase::applicationFontFamilies(id).at(0); - emit q->nameChanged(); - status = QmlFontFamily::Ready; - } else { - status = QmlFontFamily::Error; - qWarning() << "Cannot load font: " << name << url; - } - emit q->statusChanged(); -} - -QT_END_NAMESPACE diff --git a/src/declarative/util/qmlfontfamily.h b/src/declarative/util/qmlfontfamily.h deleted file mode 100644 index 17b6635..0000000 --- a/src/declarative/util/qmlfontfamily.h +++ /dev/null @@ -1,94 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMLFONTFAMILY_H -#define QMLFONTFAMILY_H - -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) - -class QmlFontFamilyPrivate; -class Q_DECLARATIVE_EXPORT QmlFontFamily : public QObject -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QmlFontFamily) - Q_ENUMS(Status) - - Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged) - Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) - Q_PROPERTY(Status status READ status NOTIFY statusChanged) - -public: - enum Status { Null = 0, Ready, Loading, Error }; - - QmlFontFamily(QObject *parent = 0); - ~QmlFontFamily(); - - QUrl source() const; - void setSource(const QUrl &url); - - QString name() const; - void setName(const QString &name); - - Status status() const; - -private Q_SLOTS: - void replyFinished(); - -Q_SIGNALS: - void nameChanged(); - void statusChanged(); -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QmlFontFamily) - -QT_END_HEADER - -#endif // QMLFONTFAMILY_H - diff --git a/src/declarative/util/util.pri b/src/declarative/util/util.pri index dfb79ac..59e3695 100644 --- a/src/declarative/util/util.pri +++ b/src/declarative/util/util.pri @@ -7,7 +7,6 @@ SOURCES += \ util/qmlscript.cpp \ util/qmlanimation.cpp \ util/qmlfont.cpp \ - util/qmlfontfamily.cpp \ util/qmlpalette.cpp \ util/qmlfollow.cpp \ util/qmlstate.cpp\ @@ -34,7 +33,6 @@ HEADERS += \ util/qmlanimation.h \ util/qmlanimation_p.h \ util/qmlfont.h \ - util/qmlfontfamily.h \ util/qmlpalette.h \ util/qmlfollow.h \ util/qmlstate.h\ -- cgit v0.12 From 28a76d03cd4f74d2619c8ab402fa97e71ce41310 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 5 Aug 2009 08:52:32 +1000 Subject: Get qmldebugger running, and add basic object/property view. --- src/declarative/debugger/qmldebug.cpp | 1 + src/declarative/qml/qmlenginedebug.cpp | 9 +- src/declarative/qml/qmlenginedebug_p.h | 1 + tools/qmldebugger/canvasscene.cpp | 248 --------------------------------- tools/qmldebugger/canvasscene.h | 43 ------ tools/qmldebugger/engine.cpp | 77 +++++++++- tools/qmldebugger/engine.h | 9 ++ tools/qmldebugger/engines.qml | 2 +- tools/qmldebugger/main.cpp | 4 - tools/qmldebugger/qmldebugger.pro | 4 +- tools/tools.pro | 2 +- 11 files changed, 93 insertions(+), 307 deletions(-) delete mode 100644 tools/qmldebugger/canvasscene.cpp delete mode 100644 tools/qmldebugger/canvasscene.h diff --git a/src/declarative/debugger/qmldebug.cpp b/src/declarative/debugger/qmldebug.cpp index 8309ec6..9397bb9 100644 --- a/src/declarative/debugger/qmldebug.cpp +++ b/src/declarative/debugger/qmldebug.cpp @@ -103,6 +103,7 @@ void QmlEngineDebugPrivate::decode(QDataStream &ds, QmlDebugObjectReference &o, ds >> data; QmlDebugPropertyReference prop; prop.m_name = data.name; + prop.m_binding = data.binding; if (data.type == QmlEngineDebugServer::QmlObjectProperty::Basic) prop.m_value = data.value; else if (data.type == QmlEngineDebugServer::QmlObjectProperty::Object) { diff --git a/src/declarative/qml/qmlenginedebug.cpp b/src/declarative/qml/qmlenginedebug.cpp index 2b8aac3..c26f3b7 100644 --- a/src/declarative/qml/qmlenginedebug.cpp +++ b/src/declarative/qml/qmlenginedebug.cpp @@ -44,6 +44,8 @@ #include #include #include +#include +#include #include "qmlcontext_p.h" QT_BEGIN_NAMESPACE @@ -73,7 +75,7 @@ QDataStream &operator>>(QDataStream &ds, QDataStream &operator<<(QDataStream &ds, const QmlEngineDebugServer::QmlObjectProperty &data) { - ds << (int)data.type << data.name << data.value; + ds << (int)data.type << data.name << data.value << data.binding; return ds; } @@ -81,7 +83,7 @@ QDataStream &operator>>(QDataStream &ds, QmlEngineDebugServer::QmlObjectProperty &data) { int type; - ds >> type >> data.name >> data.value; + ds >> type >> data.name >> data.value >> data.binding; data.type = (QmlEngineDebugServer::QmlObjectProperty::Type)type; return ds; } @@ -95,6 +97,9 @@ QmlEngineDebugServer::propertyData(QObject *obj, int propIdx) rv.type = QmlObjectProperty::Unknown; rv.name = prop.name(); + QmlBinding *binding = QmlMetaProperty(obj, rv.name).binding(); + if (binding) + rv.binding = binding->expression(); if (prop.type() < QVariant::UserType) { rv.type = QmlObjectProperty::Basic; diff --git a/src/declarative/qml/qmlenginedebug_p.h b/src/declarative/qml/qmlenginedebug_p.h index e85ab6f..87b2ffd 100644 --- a/src/declarative/qml/qmlenginedebug_p.h +++ b/src/declarative/qml/qmlenginedebug_p.h @@ -81,6 +81,7 @@ public: Type type; QString name; QVariant value; + QString binding; }; static void addEngine(QmlEngine *); diff --git a/tools/qmldebugger/canvasscene.cpp b/tools/qmldebugger/canvasscene.cpp deleted file mode 100644 index 65db9da..0000000 --- a/tools/qmldebugger/canvasscene.cpp +++ /dev/null @@ -1,248 +0,0 @@ -#include "canvasscene.h" -#include -#include -#include -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class CanvasSceneClientPlugin : public QmlDebugClient -{ -public: - CanvasSceneClientPlugin(QmlDebugConnection *, CanvasScene *s); - -protected: - void messageReceived(const QByteArray &); - -private: - void dump(QDataStream &, int indent); - CanvasScene *scene; -}; - -class QmlCanvasDebuggerItem : public QTreeWidgetItem -{ -public: - QmlCanvasDebuggerItem(QTreeWidget *tree) - : QTreeWidgetItem(tree), me(0), img(0) - { - } - - QmlCanvasDebuggerItem(QTreeWidgetItem *item) - : QTreeWidgetItem(item), me(0), img(0) - { - } - - QFxRect *me; - QFxImage *img; -}; - -CanvasSceneClientPlugin::CanvasSceneClientPlugin(QmlDebugConnection *c, - CanvasScene *s) -: QmlDebugClient(QLatin1String("CanvasScene"), c), scene(s) -{ -} - -void CanvasSceneClientPlugin::messageReceived(const QByteArray &data) -{ - QByteArray d = data; - QDataStream ds(&d, QIODevice::ReadOnly); - - scene->message(ds); -} - -void CanvasScene::message(QDataStream &ds) -{ - QList children = m_canvasRoot->children(); - qDeleteAll(children); - m_tree->clear(); - m_selected = 0; - - QTreeWidgetItem *root = new QmlCanvasDebuggerItem(m_tree); - root->setText(0, tr("Root")); - root->setExpanded(true); - clone(root, m_canvasRoot, ds); -} - -void CanvasScene::clone(QTreeWidgetItem *item, QSimpleCanvasItem *me, - QDataStream &ds) -{ - int children; - ds >> children; - - for (int ii = 0; ii < children; ++ii) { - QString name; - qreal x, y, z, width, height, scale; - QTransform transform; - bool activeFocus; - int transformOrigin, flip, options; - QPixmap pix; - - ds >> name >> x >> y >> z >> width >> height >> transformOrigin >> scale - >> flip >> transform >> activeFocus >> options >> pix; - - QmlCanvasDebuggerItem *childItem = new QmlCanvasDebuggerItem(item); - childItem->setText(0, name); - childItem->setExpanded(true); - - QFxRect *rect = new QFxRect; - rect->setParent(me); - rect->setX(x); - rect->setY(y); - rect->setZ(z); - rect->setWidth(width); - rect->setHeight(height); - rect->setTransformOrigin((QSimpleCanvasItem::TransformOrigin)transformOrigin); - rect->setScale(scale); - rect->setFlip((QSimpleCanvasItem::Flip)flip); - rect->setTransform(transform); - - if (activeFocus) - rect->setColor(QColor(0, 0, 0, 10)); - else if(options & QSimpleCanvasItem::IsFocusPanel) - rect->setColor(QColor(0, 255, 0, 10)); - else if(options & QSimpleCanvasItem::IsFocusRealm) - rect->setColor(QColor(0, 0, 255, 10)); - else - rect->setColor(QColor(255, 0, 0, 10)); - - if (pix.width() > 0 || pix.height() > 0) { - QFxImage *img = new QFxImage; - img->setParent(rect); - img->setWidth(width); - img->setHeight(height); - img->setPixmap(pix); - img->setOpacity(0); - childItem->img = img; - } - - childItem->me = rect; - - clone(childItem, rect, ds); - } -} - -void CanvasSceneClientPlugin::dump(QDataStream &ds, int indent) -{ - QString name; - qreal x, y, z, width, height, scale; - QTransform transform; - bool activeFocus; - int transformOrigin, flip, options, count; - QPixmap pix; - - ds >> name >> x >> y >> z >> width >> height >> transformOrigin >> scale - >> flip >> transform >> activeFocus >> options >> pix >> count; - - QByteArray ba(indent * 4, ' '); - qWarning() << ba.constData() << name << x << y; - - for(int ii = 0; ii < count; ++ii) - dump(ds, indent + 1); -} - -CanvasScene::CanvasScene(QmlDebugConnection *c, QWidget *parent) -: QWidget(parent) -{ - client = new CanvasSceneClientPlugin(c, this); - - QVBoxLayout *layout = new QVBoxLayout; - layout->setContentsMargins(0,0,0,0); - layout->setSpacing(0); - setLayout(layout); - QSplitter *splitter = new QSplitter(this); - - m_tree = new QTreeWidget(this); - m_tree->setHeaderHidden(true); - QObject::connect(m_tree, SIGNAL(itemExpanded(QTreeWidgetItem*)), - this, SLOT(itemExpanded(QTreeWidgetItem*))); - QObject::connect(m_tree, SIGNAL(itemCollapsed(QTreeWidgetItem*)), - this, SLOT(itemCollapsed(QTreeWidgetItem*))); - QObject::connect(m_tree, SIGNAL(itemClicked(QTreeWidgetItem*,int)), - this, SLOT(itemClicked(QTreeWidgetItem*))); - m_canvas = new QSimpleCanvas(QSimpleCanvas::SimpleCanvas, this); - m_canvasRoot = new QSimpleCanvasItem; - m_canvasRoot->setParent(m_canvas->root()); - splitter->addWidget(m_tree); - splitter->addWidget(m_canvas); - splitter->setStretchFactor(1, 2); - layout->addWidget(splitter); - - QHBoxLayout *hlayout = new QHBoxLayout; - hlayout->setContentsMargins(0,0,0,0); - hlayout->addStretch(2); - hlayout->setSpacing(0); - layout->addLayout(hlayout); - QSpinBox *x = new QSpinBox(this); - x->setSingleStep(50); - x->setMaximum(10000); - x->setMinimum(-10000); - QObject::connect(x, SIGNAL(valueChanged(int)), this, SLOT(setX(int))); - QSpinBox *y = new QSpinBox(this); - y->setSingleStep(50); - y->setMaximum(10000); - y->setMinimum(-10000); - QObject::connect(y, SIGNAL(valueChanged(int)), this, SLOT(setY(int))); - hlayout->addWidget(x); - hlayout->addWidget(y); - QPushButton *pb = new QPushButton(tr("Refresh"), this); - QObject::connect(pb, SIGNAL(clicked()), this, SLOT(refresh())); - hlayout->addWidget(pb); -} - -void CanvasScene::refresh() -{ - client->sendMessage(QByteArray()); -} - -void CanvasScene::itemExpanded(QTreeWidgetItem *i) -{ - QmlCanvasDebuggerItem *item = static_cast(i); - if(item->me) - item->me->setOpacity(1); -} - -void CanvasScene::setOpacityRecur(QTreeWidgetItem *i, qreal op) -{ - QmlCanvasDebuggerItem *item = static_cast(i); - if(item->img) - item->img->setOpacity(op); - - for(int ii = 0; ii < item->childCount(); ++ii) - setOpacityRecur(item->child(ii), op); -} - -void CanvasScene::itemClicked(QTreeWidgetItem *i) -{ - QmlCanvasDebuggerItem *item = static_cast(i); - - if(m_selected) { - setOpacityRecur(m_selected, 0); - m_selected = 0; - } - - m_selected = item; - setOpacityRecur(m_selected, 1); -} - -void CanvasScene::itemCollapsed(QTreeWidgetItem *i) -{ - QmlCanvasDebuggerItem *item = static_cast(i); - if(item->me) - item->me->setOpacity(0); -} - -void CanvasScene::setX(int x) -{ - m_canvasRoot->setX(x); -} - -void CanvasScene::setY(int y) -{ - m_canvasRoot->setY(y); -} - -QT_END_NAMESPACE diff --git a/tools/qmldebugger/canvasscene.h b/tools/qmldebugger/canvasscene.h deleted file mode 100644 index 8c6b8d5..0000000 --- a/tools/qmldebugger/canvasscene.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef CANVASSCENE_H -#define CANVASSCENE_H - -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class QmlDebugConnection; -class CanvasSceneClient; -class QmlDebugClient; -class CanvasScene : public QWidget -{ -Q_OBJECT -public: - CanvasScene(QmlDebugConnection *, QWidget *parent = 0); - - void message(QDataStream &); -private slots: - void refresh(); - void itemClicked(QTreeWidgetItem *); - void itemExpanded(QTreeWidgetItem *); - void itemCollapsed(QTreeWidgetItem *); - void setX(int); - void setY(int); - -private: - void setOpacityRecur(QTreeWidgetItem *, qreal); - void clone(QTreeWidgetItem *item, QSimpleCanvasItem *me, QDataStream &); - QmlDebugClient *client; - - QTreeWidget *m_tree; - QSimpleCanvas *m_canvas; - QSimpleCanvasItem *m_canvasRoot; - QTreeWidgetItem *m_selected; -}; - -QT_END_NAMESPACE - -#endif // CANVASSCENE_H - diff --git a/tools/qmldebugger/engine.cpp b/tools/qmldebugger/engine.cpp index 3b8c8b1..229cd3f 100644 --- a/tools/qmldebugger/engine.cpp +++ b/tools/qmldebugger/engine.cpp @@ -2,7 +2,10 @@ #include #include #include +#include #include +#include +#include #include #include #include @@ -11,9 +14,9 @@ QT_BEGIN_NAMESPACE class DebuggerEngineItem : public QObject { -Q_OBJECT -Q_PROPERTY(QString name READ name CONSTANT); -Q_PROPERTY(QString engineId READ engineId CONSTANT); + Q_OBJECT + Q_PROPERTY(QString name READ name CONSTANT); + Q_PROPERTY(int engineId READ engineId CONSTANT); public: DebuggerEngineItem(const QString &name, int id) @@ -56,7 +59,23 @@ EnginePane::EnginePane(QmlDebugConnection *client, QWidget *parent) QObject::connect(query, SIGNAL(clicked()), this, SLOT(fetchClicked())); layout->addWidget(query); - layout->addStretch(10); + QHBoxLayout *hbox = new QHBoxLayout; + hbox->setContentsMargins(0, 0, 0, 0); + + m_objTree = new QTreeWidget(this); + m_objTree->setHeaderHidden(true); + connect(m_objTree, SIGNAL(itemClicked(QTreeWidgetItem *, int)), this, SLOT(itemClicked(QTreeWidgetItem *))); + hbox->addWidget(m_objTree); + + m_propTable = new QTableWidget(this); + m_propTable->setColumnCount(2); + m_propTable->setColumnWidth(0, 150); + m_propTable->setColumnWidth(1, 400); + m_propTable->setHorizontalHeaderLabels(QStringList() << "name" << "value"); + hbox->addWidget(m_propTable); + hbox->setStretchFactor(m_propTable, 2); + + layout->addLayout(hbox); } void EnginePane::engineSelected(int id) @@ -65,6 +84,40 @@ void EnginePane::engineSelected(int id) queryContext(id); } +void EnginePane::itemClicked(QTreeWidgetItem *item) +{ + m_propTable->clearContents(); + + if (m_object) { + delete m_object; + m_object = 0; + } + + m_object = m_client.queryObjectRecursive(QmlDebugObjectReference(item->data(0, Qt::UserRole).toInt()), this); + if (!m_object->isWaiting()) + showProperties(); + else + QObject::connect(m_object, SIGNAL(stateChanged(State)), + this, SLOT(showProperties())); +} + +void EnginePane::showProperties() +{ + QmlDebugObjectReference obj = m_object->object(); + m_propTable->setRowCount(obj.properties().count()); + for (int ii = 0; ii < obj.properties().count(); ++ii) { + QTableWidgetItem *name = new QTableWidgetItem(obj.properties().at(ii).name()); + m_propTable->setItem(ii, 0, name); + QTableWidgetItem *value; + if (!obj.properties().at(ii).binding().isEmpty()) + value = new QTableWidgetItem(obj.properties().at(ii).binding()); + else + value = new QTableWidgetItem(obj.properties().at(ii).value().toString()); + m_propTable->setItem(ii, 1, value); + } + delete m_object; m_object = 0; +} + void EnginePane::queryContext(int id) { if (m_context) { @@ -110,6 +163,17 @@ void EnginePane::dump(const QmlDebugObjectReference &obj, int ind) dump(obj.children().at(ii), ind + 1); } + +void EnginePane::buildTree(const QmlDebugObjectReference &obj, QTreeWidgetItem *parent) +{ + QTreeWidgetItem *item = parent ? new QTreeWidgetItem(parent) : new QTreeWidgetItem(m_objTree); + item->setText(0, obj.className()); + item->setData(0, Qt::UserRole, obj.debugId()); + + for (int ii = 0; ii < obj.children().count(); ++ii) + buildTree(obj.children().at(ii), item); +} + void EnginePane::queryEngines() { if (m_engines) @@ -131,8 +195,8 @@ void EnginePane::enginesChanged() QList engines = m_engines->engines(); delete m_engines; m_engines = 0; - for (int ii = 0; ii < engines.count(); ++ii) - m_engineItems << new DebuggerEngineItem(engines.at(ii).name(), + for (int ii = 0; ii < engines.count(); ++ii) + m_engineItems << new DebuggerEngineItem(engines.at(ii).name(), engines.at(ii).debugId()); m_engineView->rootContext()->setContextProperty("engines", qVariantFromValue(&m_engineItems)); @@ -162,6 +226,7 @@ void EnginePane::fetchObject(int id) void EnginePane::objectFetched() { dump(m_object->object(), 0); + buildTree(m_object->object(), 0); delete m_object; m_object = 0; } diff --git a/tools/qmldebugger/engine.h b/tools/qmldebugger/engine.h index a713f25..52f0608 100644 --- a/tools/qmldebugger/engine.h +++ b/tools/qmldebugger/engine.h @@ -12,6 +12,9 @@ QT_BEGIN_NAMESPACE class QmlDebugConnection; class EngineClientPlugin; class QLineEdit; +class QTreeWidget; +class QTreeWidgetItem; +class QTableWidget; class EnginePane : public QWidget { Q_OBJECT @@ -31,9 +34,13 @@ private slots: void engineSelected(int); + void itemClicked(QTreeWidgetItem *); + void showProperties(); + private: void dump(const QmlDebugContextReference &, int); void dump(const QmlDebugObjectReference &, int); + void buildTree(const QmlDebugObjectReference &, QTreeWidgetItem *parent); QmlEngineDebug m_client; QmlDebugEnginesQuery *m_engines; @@ -41,6 +48,8 @@ private: QmlDebugObjectQuery *m_object; QLineEdit *m_text; + QTreeWidget *m_objTree; + QTableWidget *m_propTable; QFxView *m_engineView; QList m_engineItems; diff --git a/tools/qmldebugger/engines.qml b/tools/qmldebugger/engines.qml index fc364e2..eedba08 100644 --- a/tools/qmldebugger/engines.qml +++ b/tools/qmldebugger/engines.qml @@ -19,7 +19,7 @@ Item { } Text { anchors.top: Image.bottom; - text: modelData.name + "(" + modelData.engineId + ")" + text: modelData.name + "(" + modelData.engineId + ")" anchors.horizontalCenter: parent.horizontalCenter } MouseRegion { diff --git a/tools/qmldebugger/main.cpp b/tools/qmldebugger/main.cpp index 500836f..a37a437 100644 --- a/tools/qmldebugger/main.cpp +++ b/tools/qmldebugger/main.cpp @@ -8,7 +8,6 @@ #include #include #include "canvasframerate.h" -#include "canvasscene.h" #include "engine.h" #include #include @@ -75,9 +74,6 @@ Shell::Shell(QWidget *parent) CanvasFrameRate *cfr = new CanvasFrameRate(&client, this); tabs->addTab(cfr, tr("Frame Rate")); - CanvasScene *cs = new CanvasScene(&client, this); - tabs->addTab(cs, tr("Scene")); - EnginePane *ep = new EnginePane(&client, this); tabs->addTab(ep, tr("QML Engine")); diff --git a/tools/qmldebugger/qmldebugger.pro b/tools/qmldebugger/qmldebugger.pro index 1068858..532fd2a 100644 --- a/tools/qmldebugger/qmldebugger.pro +++ b/tools/qmldebugger/qmldebugger.pro @@ -3,8 +3,8 @@ QT += network declarative contains(QT_CONFIG, opengles2)|contains(QT_CONFIG, opengles1): QT += opengl # Input -HEADERS += canvasframerate.h canvasscene.h engine.h -SOURCES += main.cpp canvasframerate.cpp canvasscene.cpp engine.cpp +HEADERS += canvasframerate.h engine.h +SOURCES += main.cpp canvasframerate.cpp engine.cpp target.path=$$[QT_INSTALL_BINS] INSTALLS += target diff --git a/tools/tools.pro b/tools/tools.pro index ecdbcd1..68b4801 100644 --- a/tools/tools.pro +++ b/tools/tools.pro @@ -24,7 +24,7 @@ mac { embedded:SUBDIRS += kmap2qmap -contains(QT_CONFIG, declarative):SUBDIRS += qmlviewer +contains(QT_CONFIG, declarative):SUBDIRS += qmlviewer qmldebugger contains(QT_CONFIG, dbus):SUBDIRS += qdbus !wince*:contains(QT_CONFIG, xmlpatterns): SUBDIRS += xmlpatterns xmlpatternsvalidator embedded: SUBDIRS += makeqpf -- cgit v0.12 From 29b184cf0bdebafe6d667994543f7af6e44b709b Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Wed, 5 Aug 2009 09:12:57 +1000 Subject: Renaming: FontFamily -> FontLoader --- examples/declarative/fonts/fonts.qml | 8 +- src/declarative/extra/extra.pri | 4 +- src/declarative/extra/qmlfontfamily.cpp | 206 -------------------------------- src/declarative/extra/qmlfontfamily.h | 94 --------------- src/declarative/extra/qmlfontloader.cpp | 206 ++++++++++++++++++++++++++++++++ src/declarative/extra/qmlfontloader.h | 94 +++++++++++++++ 6 files changed, 306 insertions(+), 306 deletions(-) delete mode 100644 src/declarative/extra/qmlfontfamily.cpp delete mode 100644 src/declarative/extra/qmlfontfamily.h create mode 100644 src/declarative/extra/qmlfontloader.cpp create mode 100644 src/declarative/extra/qmlfontloader.h diff --git a/examples/declarative/fonts/fonts.qml b/examples/declarative/fonts/fonts.qml index eb8cfef..c981e51 100644 --- a/examples/declarative/fonts/fonts.qml +++ b/examples/declarative/fonts/fonts.qml @@ -8,13 +8,13 @@ Rect { Palette { id: Palette; colorGroup: "Active" } - FontFamily { id: FixedFont; name: "Courier" } + FontLoader { id: FixedFont; name: "Courier" } - FontFamily { id: LocalFont; source: "fonts/Fontin-Bold.ttf" } + FontLoader { id: LocalFont; source: "fonts/Fontin-Bold.ttf" } /* A font by Jos Buivenga (exljbris) -> www.exljbris.nl */ - FontFamily { id: WebFont; source: "http://www.princexml.com/fonts/steffmann/Starburst.ttf" } - FontFamily { id: WebFont2; source: "http://wrong.address.org" } + FontLoader { id: WebFont; source: "http://www.princexml.com/fonts/steffmann/Starburst.ttf" } + FontLoader { id: WebFont2; source: "http://wrong.address.org" } VerticalLayout { anchors.fill: parent diff --git a/src/declarative/extra/extra.pri b/src/declarative/extra/extra.pri index c731afa..1f84406 100644 --- a/src/declarative/extra/extra.pri +++ b/src/declarative/extra/extra.pri @@ -9,7 +9,7 @@ SOURCES += \ extra/qfxparticles.cpp \ extra/qmlbehaviour.cpp \ extra/qbindablemap.cpp \ - extra/qmlfontfamily.cpp + extra/qmlfontloader.cpp HEADERS += \ extra/qnumberformat.h \ @@ -23,7 +23,7 @@ HEADERS += \ extra/qfxparticles.h \ extra/qmlbehaviour.h \ extra/qbindablemap.h \ - extra/qmlfontfamily.h + extra/qmlfontloader.h contains(QT_CONFIG, xmlpatterns) { QT+=xmlpatterns diff --git a/src/declarative/extra/qmlfontfamily.cpp b/src/declarative/extra/qmlfontfamily.cpp deleted file mode 100644 index 73688c1..0000000 --- a/src/declarative/extra/qmlfontfamily.cpp +++ /dev/null @@ -1,206 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "private/qobject_p.h" -#include "qmlfontfamily.h" -#include -#include -#include -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class QmlFontFamilyPrivate : public QObjectPrivate -{ - Q_DECLARE_PUBLIC(QmlFontFamily); - -public: - QmlFontFamilyPrivate() : reply(0), status(QmlFontFamily::Null) {} - - void addFontToDatabase(const QByteArray &); - - QUrl url; - QString name; - QNetworkReply *reply; - QmlFontFamily::Status status; -}; - -QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,FontFamily,QmlFontFamily) - -/*! - \qmlclass FontFamily QmlFontFamily - \ingroup group_utility - \brief This item allows using fonts by name or url. - - Example: - \code - FontFamily { id: FixedFont; name: "Courier" } - FontFamily { id: WebFont; source: "http://www.mysite.com/myfont.ttf" } - - Text { text: "Fixed-size font"; font.family: FixedFont.name } - Text { text: "Fancy font"; font.family: WebFont.name } - \endcode -*/ -QmlFontFamily::QmlFontFamily(QObject *parent) - : QObject(*(new QmlFontFamilyPrivate), parent) -{ -} - -QmlFontFamily::~QmlFontFamily() -{ -} - -/*! - \qmlproperty url FontFamily::source - The url of the font to load. -*/ -QUrl QmlFontFamily::source() const -{ - Q_D(const QmlFontFamily); - return d->url; -} - -void QmlFontFamily::setSource(const QUrl &url) -{ - Q_D(QmlFontFamily); - if (url == d->url) - return; - d->url = qmlContext(this)->resolvedUrl(url); - - d->status = Loading; - emit statusChanged(); -#ifndef QT_NO_LOCALFILE_OPTIMIZED_QML - if (d->url.scheme() == QLatin1String("file")) { - QFile file(d->url.toLocalFile()); - file.open(QIODevice::ReadOnly); - QByteArray ba = file.readAll(); - d->addFontToDatabase(ba); - } else -#endif - { - QNetworkRequest req(d->url); - req.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache); - d->reply = qmlEngine(this)->networkAccessManager()->get(req); - QObject::connect(d->reply, SIGNAL(finished()), this, SLOT(replyFinished())); - } -} - -/*! - \qmlproperty string FontFamily::name - - This property holds the name of the font family. - It is set automatically when a font is loaded using the \c url property. - - Use this to set the \c font.family property of a \c Text item. - - Example: - \qml - FontFamily { id: WebFont; source: "http://www.mysite.com/myfont.ttf" } - Text { text: "Fancy font"; font.family: WebFont.name } - \endqml -*/ -QString QmlFontFamily::name() const -{ - Q_D(const QmlFontFamily); - return d->name; -} - -void QmlFontFamily::setName(const QString &name) -{ - Q_D(QmlFontFamily); - if (d->name == name ) - return; - d->name = name; - emit nameChanged(); -} - -/*! - \qmlproperty enum FontFamily::status - - This property holds the status of font loading. It can be one of: - \list - \o Null - no font has been set - \o Ready - the font has been loaded - \o Loading - the font is currently being loaded - \o Error - an error occurred while loading the font - \endlist -*/ -QmlFontFamily::Status QmlFontFamily::status() const -{ - Q_D(const QmlFontFamily); - return d->status; -} - -void QmlFontFamily::replyFinished() -{ - Q_D(QmlFontFamily); - if (!d->reply->error()) { - QByteArray ba = d->reply->readAll(); - d->addFontToDatabase(ba); - } else { - d->status = Error; - emit statusChanged(); - } - d->reply->deleteLater(); - d->reply = 0; -} - -void QmlFontFamilyPrivate::addFontToDatabase(const QByteArray &ba) -{ - Q_Q(QmlFontFamily); - - int id = QFontDatabase::addApplicationFontFromData(ba); - if (id != -1) { - name = QFontDatabase::applicationFontFamilies(id).at(0); - emit q->nameChanged(); - status = QmlFontFamily::Ready; - } else { - status = QmlFontFamily::Error; - qWarning() << "Cannot load font: " << name << url; - } - emit q->statusChanged(); -} - -QT_END_NAMESPACE diff --git a/src/declarative/extra/qmlfontfamily.h b/src/declarative/extra/qmlfontfamily.h deleted file mode 100644 index 17b6635..0000000 --- a/src/declarative/extra/qmlfontfamily.h +++ /dev/null @@ -1,94 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMLFONTFAMILY_H -#define QMLFONTFAMILY_H - -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) - -class QmlFontFamilyPrivate; -class Q_DECLARATIVE_EXPORT QmlFontFamily : public QObject -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QmlFontFamily) - Q_ENUMS(Status) - - Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged) - Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) - Q_PROPERTY(Status status READ status NOTIFY statusChanged) - -public: - enum Status { Null = 0, Ready, Loading, Error }; - - QmlFontFamily(QObject *parent = 0); - ~QmlFontFamily(); - - QUrl source() const; - void setSource(const QUrl &url); - - QString name() const; - void setName(const QString &name); - - Status status() const; - -private Q_SLOTS: - void replyFinished(); - -Q_SIGNALS: - void nameChanged(); - void statusChanged(); -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QmlFontFamily) - -QT_END_HEADER - -#endif // QMLFONTFAMILY_H - diff --git a/src/declarative/extra/qmlfontloader.cpp b/src/declarative/extra/qmlfontloader.cpp new file mode 100644 index 0000000..2f54f24 --- /dev/null +++ b/src/declarative/extra/qmlfontloader.cpp @@ -0,0 +1,206 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "private/qobject_p.h" +#include "qmlfontloader.h" +#include +#include +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class QmlFontLoaderPrivate : public QObjectPrivate +{ + Q_DECLARE_PUBLIC(QmlFontLoader); + +public: + QmlFontLoaderPrivate() : reply(0), status(QmlFontLoader::Null) {} + + void addFontToDatabase(const QByteArray &); + + QUrl url; + QString name; + QNetworkReply *reply; + QmlFontLoader::Status status; +}; + +QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,FontLoader,QmlFontLoader) + +/*! + \qmlclass FontLoader QmlFontLoader + \ingroup group_utility + \brief This item allows using fonts by name or url. + + Example: + \code + FontLoader { id: FixedFont; name: "Courier" } + FontLoader { id: WebFont; source: "http://www.mysite.com/myfont.ttf" } + + Text { text: "Fixed-size font"; font.family: FixedFont.name } + Text { text: "Fancy font"; font.family: WebFont.name } + \endcode +*/ +QmlFontLoader::QmlFontLoader(QObject *parent) + : QObject(*(new QmlFontLoaderPrivate), parent) +{ +} + +QmlFontLoader::~QmlFontLoader() +{ +} + +/*! + \qmlproperty url FontLoader::source + The url of the font to load. +*/ +QUrl QmlFontLoader::source() const +{ + Q_D(const QmlFontLoader); + return d->url; +} + +void QmlFontLoader::setSource(const QUrl &url) +{ + Q_D(QmlFontLoader); + if (url == d->url) + return; + d->url = qmlContext(this)->resolvedUrl(url); + + d->status = Loading; + emit statusChanged(); +#ifndef QT_NO_LOCALFILE_OPTIMIZED_QML + if (d->url.scheme() == QLatin1String("file")) { + QFile file(d->url.toLocalFile()); + file.open(QIODevice::ReadOnly); + QByteArray ba = file.readAll(); + d->addFontToDatabase(ba); + } else +#endif + { + QNetworkRequest req(d->url); + req.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache); + d->reply = qmlEngine(this)->networkAccessManager()->get(req); + QObject::connect(d->reply, SIGNAL(finished()), this, SLOT(replyFinished())); + } +} + +/*! + \qmlproperty string FontLoader::name + + This property holds the name of the font family. + It is set automatically when a font is loaded using the \c url property. + + Use this to set the \c font.family property of a \c Text item. + + Example: + \qml + FontLoader { id: WebFont; source: "http://www.mysite.com/myfont.ttf" } + Text { text: "Fancy font"; font.family: WebFont.name } + \endqml +*/ +QString QmlFontLoader::name() const +{ + Q_D(const QmlFontLoader); + return d->name; +} + +void QmlFontLoader::setName(const QString &name) +{ + Q_D(QmlFontLoader); + if (d->name == name ) + return; + d->name = name; + emit nameChanged(); +} + +/*! + \qmlproperty enum FontLoader::status + + This property holds the status of font loading. It can be one of: + \list + \o Null - no font has been set + \o Ready - the font has been loaded + \o Loading - the font is currently being loaded + \o Error - an error occurred while loading the font + \endlist +*/ +QmlFontLoader::Status QmlFontLoader::status() const +{ + Q_D(const QmlFontLoader); + return d->status; +} + +void QmlFontLoader::replyFinished() +{ + Q_D(QmlFontLoader); + if (!d->reply->error()) { + QByteArray ba = d->reply->readAll(); + d->addFontToDatabase(ba); + } else { + d->status = Error; + emit statusChanged(); + } + d->reply->deleteLater(); + d->reply = 0; +} + +void QmlFontLoaderPrivate::addFontToDatabase(const QByteArray &ba) +{ + Q_Q(QmlFontLoader); + + int id = QFontDatabase::addApplicationFontFromData(ba); + if (id != -1) { + name = QFontDatabase::applicationFontFamilies(id).at(0); + emit q->nameChanged(); + status = QmlFontLoader::Ready; + } else { + status = QmlFontLoader::Error; + qWarning() << "Cannot load font: " << name << url; + } + emit q->statusChanged(); +} + +QT_END_NAMESPACE diff --git a/src/declarative/extra/qmlfontloader.h b/src/declarative/extra/qmlfontloader.h new file mode 100644 index 0000000..c2c7a16 --- /dev/null +++ b/src/declarative/extra/qmlfontloader.h @@ -0,0 +1,94 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMLFONTLOADER_H +#define QMLFONTLOADER_H + +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) + +class QmlFontLoaderPrivate; +class Q_DECLARATIVE_EXPORT QmlFontLoader : public QObject +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QmlFontLoader) + Q_ENUMS(Status) + + Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged) + Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) + Q_PROPERTY(Status status READ status NOTIFY statusChanged) + +public: + enum Status { Null = 0, Ready, Loading, Error }; + + QmlFontLoader(QObject *parent = 0); + ~QmlFontLoader(); + + QUrl source() const; + void setSource(const QUrl &url); + + QString name() const; + void setName(const QString &name); + + Status status() const; + +private Q_SLOTS: + void replyFinished(); + +Q_SIGNALS: + void nameChanged(); + void statusChanged(); +}; + +QT_END_NAMESPACE + +QML_DECLARE_TYPE(QmlFontLoader) + +QT_END_HEADER + +#endif // QMLFONTLOADER_H + -- cgit v0.12 From 5b5ce7bef24f6bc8bc984ca95f464ee8d893d34b Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Wed, 5 Aug 2009 10:53:33 +1000 Subject: Fix test "interface" is a JS reserved word, which have been disallowed as property names. --- tests/auto/declarative/qmlparser/interfaceProperty.txt | 4 ++-- tests/auto/declarative/qmlparser/testtypes.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/auto/declarative/qmlparser/interfaceProperty.txt b/tests/auto/declarative/qmlparser/interfaceProperty.txt index c9a20fb..70879ff 100644 --- a/tests/auto/declarative/qmlparser/interfaceProperty.txt +++ b/tests/auto/declarative/qmlparser/interfaceProperty.txt @@ -1,5 +1,5 @@ import Test 1.0 import Qt 4.6 -Object { - interface: MyQmlObject {} +MyQmlObject { + interfaceProperty: MyQmlObject {} } diff --git a/tests/auto/declarative/qmlparser/testtypes.h b/tests/auto/declarative/qmlparser/testtypes.h index 34f3616..ace7ef9 100644 --- a/tests/auto/declarative/qmlparser/testtypes.h +++ b/tests/auto/declarative/qmlparser/testtypes.h @@ -56,7 +56,7 @@ class MyQmlObject : public QObject, public MyInterface, public QmlParserStatus Q_PROPERTY(bool enabled READ enabled WRITE setEnabled) Q_PROPERTY(QRect rect READ rect WRITE setRect) Q_PROPERTY(QMatrix matrix READ matrix WRITE setMatrix) //assumed to be unsupported by QML - Q_PROPERTY(MyInterface *interface READ interface WRITE setInterface) + Q_PROPERTY(MyInterface *interfaceProperty READ interface WRITE setInterface) Q_PROPERTY(int onLiteralSignal READ onLiteralSignal WRITE setOnLiteralSignal); Q_PROPERTY(MyCustomVariantType customType READ customType WRITE setCustomType); Q_INTERFACES(MyInterface QmlParserStatus) -- cgit v0.12 From dcb3dc40abc18cedfa0c984a9a6fe693c6b5789c Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Wed, 5 Aug 2009 11:30:54 +1000 Subject: Fixup QPoint and QRect value types The floating point and integer point/rect classes are not binary compatible, as change e494fef4cd3fd2dbec273fc48c49f8d15469bc96 assumed. --- src/declarative/qml/qmlvaluetype.cpp | 124 +++++++++++++++++++++++++++++++---- src/declarative/qml/qmlvaluetype_p.h | 55 ++++++++++++++-- 2 files changed, 161 insertions(+), 18 deletions(-) diff --git a/src/declarative/qml/qmlvaluetype.cpp b/src/declarative/qml/qmlvaluetype.cpp index ca968fc..b827572 100644 --- a/src/declarative/qml/qmlvaluetype.cpp +++ b/src/declarative/qml/qmlvaluetype.cpp @@ -60,11 +60,13 @@ QmlValueType *QmlValueTypeFactory::valueType(int t) { switch (t) { case QVariant::Point: - case QVariant::PointF: return new QmlPointValueType; + case QVariant::PointF: + return new QmlPointFValueType; case QVariant::Rect: - case QVariant::RectF: return new QmlRectValueType; + case QVariant::RectF: + return new QmlRectFValueType; case QVariant::Vector3D: return new QmlVector3DValueType; default: @@ -77,6 +79,43 @@ QmlValueType::QmlValueType(QObject *parent) { } +QmlPointFValueType::QmlPointFValueType(QObject *parent) +: QmlValueType(parent) +{ +} + +void QmlPointFValueType::read(QObject *obj, int idx) +{ + void *a[] = { &point, 0 }; + QMetaObject::metacall(obj, QMetaObject::ReadProperty, idx, a); +} + +void QmlPointFValueType::write(QObject *obj, int idx) +{ + void *a[] = { &point, 0 }; + QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a); +} + +qreal QmlPointFValueType::x() const +{ + return point.x(); +} + +qreal QmlPointFValueType::y() const +{ + return point.y(); +} + +void QmlPointFValueType::setX(qreal x) +{ + point.setX(x); +} + +void QmlPointFValueType::setY(qreal y) +{ + point.setY(y); +} + QmlPointValueType::QmlPointValueType(QObject *parent) : QmlValueType(parent) { @@ -94,26 +133,83 @@ void QmlPointValueType::write(QObject *obj, int idx) QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a); } -qreal QmlPointValueType::x() const +int QmlPointValueType::x() const { return point.x(); } -qreal QmlPointValueType::y() const +int QmlPointValueType::y() const { return point.y(); } -void QmlPointValueType::setX(qreal x) +void QmlPointValueType::setX(int x) { point.setX(x); } -void QmlPointValueType::setY(qreal y) +void QmlPointValueType::setY(int y) { point.setY(y); } +QmlRectFValueType::QmlRectFValueType(QObject *parent) +: QmlValueType(parent) +{ +} + +void QmlRectFValueType::read(QObject *obj, int idx) +{ + void *a[] = { &rect, 0 }; + QMetaObject::metacall(obj, QMetaObject::ReadProperty, idx, a); +} + +void QmlRectFValueType::write(QObject *obj, int idx) +{ + void *a[] = { &rect, 0 }; + QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a); +} + +qreal QmlRectFValueType::x() const +{ + return rect.x(); +} + +qreal QmlRectFValueType::y() const +{ + return rect.y(); +} + +void QmlRectFValueType::setX(qreal x) +{ + rect.moveLeft(x); +} + +void QmlRectFValueType::setY(qreal y) +{ + rect.moveTop(y); +} + +qreal QmlRectFValueType::width() const +{ + return rect.width(); +} + +qreal QmlRectFValueType::height() const +{ + return rect.height(); +} + +void QmlRectFValueType::setWidth(qreal w) +{ + rect.setWidth(w); +} + +void QmlRectFValueType::setHeight(qreal h) +{ + rect.setHeight(h); +} + QmlRectValueType::QmlRectValueType(QObject *parent) : QmlValueType(parent) { @@ -131,42 +227,42 @@ void QmlRectValueType::write(QObject *obj, int idx) QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a); } -qreal QmlRectValueType::x() const +int QmlRectValueType::x() const { return rect.x(); } -qreal QmlRectValueType::y() const +int QmlRectValueType::y() const { return rect.y(); } -void QmlRectValueType::setX(qreal x) +void QmlRectValueType::setX(int x) { rect.moveLeft(x); } -void QmlRectValueType::setY(qreal y) +void QmlRectValueType::setY(int y) { rect.moveTop(y); } -qreal QmlRectValueType::width() const +int QmlRectValueType::width() const { return rect.width(); } -qreal QmlRectValueType::height() const +int QmlRectValueType::height() const { return rect.height(); } -void QmlRectValueType::setWidth(qreal w) +void QmlRectValueType::setWidth(int w) { rect.setWidth(w); } -void QmlRectValueType::setHeight(qreal h) +void QmlRectValueType::setHeight(int h) { rect.setHeight(h); } diff --git a/src/declarative/qml/qmlvaluetype_p.h b/src/declarative/qml/qmlvaluetype_p.h index 9195c61..0c9e279 100644 --- a/src/declarative/qml/qmlvaluetype_p.h +++ b/src/declarative/qml/qmlvaluetype_p.h @@ -80,13 +80,13 @@ public: QmlValueType *operator[](int idx) const { return valueTypes[idx]; } }; -class QmlPointValueType : public QmlValueType +class QmlPointFValueType : public QmlValueType { Q_PROPERTY(qreal x READ x WRITE setX); Q_PROPERTY(qreal y READ y WRITE setY); Q_OBJECT public: - QmlPointValueType(QObject *parent = 0); + QmlPointFValueType(QObject *parent = 0); virtual void read(QObject *, int); virtual void write(QObject *, int); @@ -100,7 +100,27 @@ private: QPointF point; }; -class QmlRectValueType : public QmlValueType +class QmlPointValueType : public QmlValueType +{ + Q_PROPERTY(int x READ x WRITE setX); + Q_PROPERTY(int y READ y WRITE setY); + Q_OBJECT +public: + QmlPointValueType(QObject *parent = 0); + + virtual void read(QObject *, int); + virtual void write(QObject *, int); + + int x() const; + int y() const; + void setX(int); + void setY(int); + +private: + QPoint point; +}; + +class QmlRectFValueType : public QmlValueType { Q_PROPERTY(qreal x READ x WRITE setX); Q_PROPERTY(qreal y READ y WRITE setY); @@ -108,7 +128,7 @@ class QmlRectValueType : public QmlValueType Q_PROPERTY(qreal height READ height WRITE setHeight); Q_OBJECT public: - QmlRectValueType(QObject *parent = 0); + QmlRectFValueType(QObject *parent = 0); virtual void read(QObject *, int); virtual void write(QObject *, int); @@ -127,6 +147,33 @@ private: QRectF rect; }; +class QmlRectValueType : public QmlValueType +{ + Q_PROPERTY(int x READ x WRITE setX); + Q_PROPERTY(int y READ y WRITE setY); + Q_PROPERTY(int width READ width WRITE setWidth); + Q_PROPERTY(int height READ height WRITE setHeight); + Q_OBJECT +public: + QmlRectValueType(QObject *parent = 0); + + virtual void read(QObject *, int); + virtual void write(QObject *, int); + + int x() const; + int y() const; + void setX(int); + void setY(int); + + int width() const; + int height() const; + void setWidth(int); + void setHeight(int); + +private: + QRect rect; +}; + class QmlVector3DValueType : public QmlValueType { Q_PROPERTY(qreal x READ x WRITE setX); -- cgit v0.12 From b8d8ae2dc5be1a90b65faeb94ca188beda46dc1e Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Wed, 5 Aug 2009 11:56:44 +1000 Subject: Make QFxAnchorLine private and internal --- src/declarative/fx/qfxanchors.cpp | 3 +++ src/declarative/fx/qfxanchors.h | 2 +- src/declarative/fx/qfxanchors_p.h | 25 +++++++++++++++++++++++++ src/declarative/fx/qfxitem.cpp | 6 +++++- src/declarative/fx/qfxitem.h | 25 +------------------------ src/declarative/fx/qfxitem_p.h | 1 + src/declarative/util/qfxview.cpp | 1 - src/declarative/util/qmlstateoperations.cpp | 4 ++++ 8 files changed, 40 insertions(+), 27 deletions(-) diff --git a/src/declarative/fx/qfxanchors.cpp b/src/declarative/fx/qfxanchors.cpp index 1595f57..b60990c 100644 --- a/src/declarative/fx/qfxanchors.cpp +++ b/src/declarative/fx/qfxanchors.cpp @@ -969,3 +969,6 @@ bool QFxAnchorsPrivate::checkVAnchorValid(QFxAnchorLine anchor) const } QT_END_NAMESPACE + +#include "moc_qfxanchors.cpp" + diff --git a/src/declarative/fx/qfxanchors.h b/src/declarative/fx/qfxanchors.h index 70217d6..3dd64c7 100644 --- a/src/declarative/fx/qfxanchors.h +++ b/src/declarative/fx/qfxanchors.h @@ -54,6 +54,7 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) class QFxAnchorsPrivate; +class QFxAnchorLine; class Q_DECLARATIVE_EXPORT QFxAnchors : public QObject { Q_OBJECT @@ -172,7 +173,6 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(QFxAnchors::UsedAnchors) QT_END_NAMESPACE -Q_DECLARE_METATYPE(QFxAnchorLine) QML_DECLARE_TYPE(QFxAnchors) QT_END_HEADER diff --git a/src/declarative/fx/qfxanchors_p.h b/src/declarative/fx/qfxanchors_p.h index ca42966..9b1bc18 100644 --- a/src/declarative/fx/qfxanchors_p.h +++ b/src/declarative/fx/qfxanchors_p.h @@ -58,6 +58,31 @@ QT_BEGIN_NAMESPACE +class QFxAnchorLine +{ +public: + QFxAnchorLine() : item(0), anchorLine(Invalid) + { + } + + enum AnchorLine { + Invalid = 0x0, + Left = 0x01, + Right = 0x02, + Top = 0x04, + Bottom = 0x08, + HCenter = 0x10, + VCenter = 0x20, + Baseline = 0x40, + Horizontal_Mask = Left | Right | HCenter, + Vertical_Mask = Top | Bottom | VCenter | Baseline + }; + + QFxItem *item; + AnchorLine anchorLine; +}; +Q_DECLARE_METATYPE(QFxAnchorLine) + class QFxAnchorsPrivate : public QObjectPrivate { Q_DECLARE_PUBLIC(QFxAnchors) diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index 2d3fa8d..b081edc 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -53,7 +53,6 @@ #include #include "qmlstate.h" #include "qlistmodelinterface.h" -#include "qfxanchors_p.h" #include "qfxview.h" #include "qmlstategroup.h" @@ -371,6 +370,7 @@ QFxItem::QFxItem(QFxItem* parent) : QGraphicsObject(*(new QFxItemPrivate), parent, 0) { Q_D(QFxItem); + qRegisterMetaType("QFxAnchorLine"); d->init(parent); } @@ -380,6 +380,7 @@ QFxItem::QFxItem(QFxItemPrivate &dd, QFxItem *parent) : QGraphicsObject(dd, parent, 0) { Q_D(QFxItem); + qRegisterMetaType("QFxAnchorLine"); d->init(parent); } @@ -1884,3 +1885,6 @@ bool QFxItem::event(QEvent *ev) } QT_END_NAMESPACE + +#include "moc_qfxitem.cpp" + diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h index b1676e4..4a26c9b 100644 --- a/src/declarative/fx/qfxitem.h +++ b/src/declarative/fx/qfxitem.h @@ -89,31 +89,8 @@ private: qreal m_width; }; -class QFxAnchorLine -{ -public: - QFxAnchorLine() : item(0), anchorLine(Invalid) - { - } - - enum AnchorLine { - Invalid = 0x0, - Left = 0x01, - Right = 0x02, - Top = 0x04, - Bottom = 0x08, - HCenter = 0x10, - VCenter = 0x20, - Baseline = 0x40, - Horizontal_Mask = Left | Right | HCenter, - Vertical_Mask = Top | Bottom | VCenter | Baseline - }; - - QFxItem *item; - AnchorLine anchorLine; -}; - class QmlState; +class QFxAnchorLine; class QmlTransition; class QFxKeyEvent; class QFxAnchors; diff --git a/src/declarative/fx/qfxitem_p.h b/src/declarative/fx/qfxitem_p.h index b11b812..08d173d 100644 --- a/src/declarative/fx/qfxitem_p.h +++ b/src/declarative/fx/qfxitem_p.h @@ -57,6 +57,7 @@ #include #include #include +#include #include #include #include diff --git a/src/declarative/util/qfxview.cpp b/src/declarative/util/qfxview.cpp index 2f5cdd3..0f129d8 100644 --- a/src/declarative/util/qfxview.cpp +++ b/src/declarative/util/qfxview.cpp @@ -140,7 +140,6 @@ QFxView::QFxView(QWidget *parent) void QFxViewPrivate::init() { // XXX: These need to be put in a central location for this kind of thing - qRegisterMetaType("QFxAnchorLine"); QmlMetaType::registerCustomStringConverter(QVariant::Pixmap, &stringToPixmap); QmlMetaType::registerCustomStringConverter(QVariant::Icon, &stringToIcon); diff --git a/src/declarative/util/qmlstateoperations.cpp b/src/declarative/util/qmlstateoperations.cpp index 1f53bee..056912f 100644 --- a/src/declarative/util/qmlstateoperations.cpp +++ b/src/declarative/util/qmlstateoperations.cpp @@ -46,6 +46,7 @@ #include "qmlstateoperations.h" #include #include +#include QT_BEGIN_NAMESPACE @@ -524,3 +525,6 @@ void QmlSetAnchors::clearReverseBindings() } QT_END_NAMESPACE + +#include "moc_qmlstateoperations.cpp" + -- cgit v0.12 From 2995f6eee6f718487c5f982c23cc6a4318fc58bb Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Wed, 5 Aug 2009 13:24:43 +1000 Subject: Remove unnecessary friend --- src/declarative/qml/qmlexpression.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/declarative/qml/qmlexpression.h b/src/declarative/qml/qmlexpression.h index d5f0cbb..c295a1c 100644 --- a/src/declarative/qml/qmlexpression.h +++ b/src/declarative/qml/qmlexpression.h @@ -97,7 +97,6 @@ private Q_SLOTS: private: Q_DECLARE_PRIVATE(QmlExpression) - friend class QmlExpressionBindProxy; friend class QmlDebugger; friend class QmlContext; }; -- cgit v0.12 From 3c85728f2cb69817d4b72d3aab16b7a7fe6bdbf0 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Wed, 5 Aug 2009 14:15:10 +1000 Subject: Rewrite bindings inside the compiler To improve execution performance, binding expressions are rewritten as function closures inside QmlExpression. To improve startup performance, where possible, the expressions are rewritten inside the compiler instead of inside QmlExpression at runtime. This also has the sideeffect of removing the StoreBinding instruction, as all bindings are now "compiled". The QmlBinding::expression() method for rewritten bindings will now return the rewritten expression instead of the original (which is lost), but this API is internal anyway. --- src/declarative/qml/qmlcompiler.cpp | 43 ++++++++++++++++++++++------------ src/declarative/qml/qmlexpression.cpp | 24 +++++++++++++++---- src/declarative/qml/qmlexpression_p.h | 8 ++++++- src/declarative/qml/qmlinstruction.cpp | 3 --- src/declarative/qml/qmlinstruction_p.h | 1 - src/declarative/qml/qmlvme.cpp | 22 ----------------- 6 files changed, 54 insertions(+), 47 deletions(-) diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp index 197bd44..6ef7cc2 100644 --- a/src/declarative/qml/qmlcompiler.cpp +++ b/src/declarative/qml/qmlcompiler.cpp @@ -64,7 +64,9 @@ #include #include "parser/qmljsast_p.h" #include +#include #include "qmlmetaproperty_p.h" +#include "qmlrewrite_p.h" #include "qmlscriptparser_p.h" @@ -2062,14 +2064,11 @@ void QmlCompiler::genBindingAssignment(QmlParser::Value *binding, const BindingReference &ref = compileState.bindings.value(binding); QmlInstruction store; - int dataRef; - if (ref.compiledData.isEmpty()) { - dataRef = output->indexForString(ref.expression.asScript()); - store.type = QmlInstruction::StoreBinding; - } else { - dataRef = output->indexForByteArray(ref.compiledData); - store.type = QmlInstruction::StoreCompiledBinding; - } + store.type = QmlInstruction::StoreCompiledBinding; + store.assignBinding.value = output->indexForByteArray(ref.compiledData); + store.assignBinding.context = ref.bindingContext.stack; + store.assignBinding.owner = ref.bindingContext.owner; + store.line = prop->location.end.line; Q_ASSERT(ref.bindingContext.owner == 0 || (ref.bindingContext.owner != 0 && valueTypeProperty)); @@ -2081,18 +2080,12 @@ void QmlCompiler::genBindingAssignment(QmlParser::Value *binding, store.assignBinding.property = QmlMetaPropertyPrivate::saveProperty(prop->index); } - store.assignBinding.value = dataRef; - store.assignBinding.context = ref.bindingContext.stack; - store.assignBinding.owner = ref.bindingContext.owner; - store.line = prop->location.end.line; output->bytecode << store; } bool QmlCompiler::completeComponentBuild() { - saveComponentState(); - for (int ii = 0; ii < compileState.aliasingObjects.count(); ++ii) { Object *aliasObject = compileState.aliasingObjects.at(ii); COMPILE_CHECK(buildDynamicMeta(aliasObject, ResolveAliases)); @@ -2111,11 +2104,31 @@ bool QmlCompiler::completeComponentBuild() expr.expression = binding.expression; bs.compile(expr); - if (bs.isValid()) + quint32 type; + if (bs.isValid()) { binding.compiledData = QByteArray(bs.compileData(), bs.compileDataSize()); + type = QmlExpressionPrivate::BasicScriptEngineData; + } else { + type = QmlExpressionPrivate::PreTransformedQtScriptData; + + // Pre-rewrite the expression + QString expression = binding.expression.asScript(); + QmlRewrite::RewriteBinding rewriteBinding; + expression = rewriteBinding(expression); + + quint32 length = expression.length(); + binding.compiledData = + QByteArray((const char *)&length, sizeof(quint32)) + + QByteArray((const char *)expression.constData(), + expression.length() * sizeof(QChar)); + } + binding.compiledData.prepend(QByteArray((const char *)&type, + sizeof(quint32))); } + saveComponentState(); + return true; } diff --git a/src/declarative/qml/qmlexpression.cpp b/src/declarative/qml/qmlexpression.cpp index 2c06efa..148ff71 100644 --- a/src/declarative/qml/qmlexpression.cpp +++ b/src/declarative/qml/qmlexpression.cpp @@ -51,7 +51,7 @@ Q_DECLARE_METATYPE(QList); QT_BEGIN_NAMESPACE QmlExpressionPrivate::QmlExpressionPrivate() -: ctxt(0), expressionFunctionValid(false), sseData(0), me(0), trackChange(true), line(-1), guardList(0), guardListLength(0) +: ctxt(0), expressionFunctionValid(false), expressionRewritten(false), sseData(0), me(0), trackChange(true), line(-1), guardList(0), guardListLength(0) { } @@ -73,7 +73,15 @@ void QmlExpressionPrivate::init(QmlContext *ctxt, void *expr, QmlRefCount *rc, { Q_Q(QmlExpression); - sse.load((const char *)expr, rc); + quint32 *data = (quint32 *)expr; + Q_ASSERT(*data == BasicScriptEngineData || + *data == PreTransformedQtScriptData); + if (*data == BasicScriptEngineData) { + sse.load((const char *)(data + 1), rc); + } else { + expression = QString::fromRawData((QChar *)(data + 2), data[1]); + expressionRewritten = true; + } this->ctxt = ctxt; if (ctxt) @@ -203,6 +211,7 @@ void QmlExpression::setExpression(const QString &expression) d->expression = expression; d->expressionFunctionValid = false; + d->expressionRewritten = false; d->expressionFunction = QScriptValue(); d->sse.clear(); @@ -250,10 +259,15 @@ QVariant QmlExpressionPrivate::evalQtScript() scriptEngine->currentContext()->pushScope(ctxtPriv->scopeChain.at(i)); if (!expressionFunctionValid) { - QmlRewrite::RewriteBinding rewriteBinding; - const QString code = rewriteBinding(expression); - expressionFunction = scriptEngine->evaluate(code, fileName, line); + if (expressionRewritten) { + expressionFunction = scriptEngine->evaluate(expression, fileName, line); + } else { + QmlRewrite::RewriteBinding rewriteBinding; + + const QString code = rewriteBinding(expression); + expressionFunction = scriptEngine->evaluate(code, fileName, line); + } expressionFunctionValid = true; } diff --git a/src/declarative/qml/qmlexpression_p.h b/src/declarative/qml/qmlexpression_p.h index cb89ce0..5ecc24d 100644 --- a/src/declarative/qml/qmlexpression_p.h +++ b/src/declarative/qml/qmlexpression_p.h @@ -70,12 +70,18 @@ public: QmlExpressionPrivate(); ~QmlExpressionPrivate(); + enum CompiledDataType { + BasicScriptEngineData = 1, + PreTransformedQtScriptData = 2 + }; + void init(QmlContext *, const QString &, QObject *); void init(QmlContext *, void *, QmlRefCount *, QObject *); QmlContext *ctxt; QString expression; - bool expressionFunctionValid; + bool expressionFunctionValid:1; + bool expressionRewritten:1; QScriptValue expressionFunction; QmlBasicScript sse; diff --git a/src/declarative/qml/qmlinstruction.cpp b/src/declarative/qml/qmlinstruction.cpp index 9f77bc0..889a057 100644 --- a/src/declarative/qml/qmlinstruction.cpp +++ b/src/declarative/qml/qmlinstruction.cpp @@ -140,9 +140,6 @@ void QmlCompiledData::dump(QmlInstruction *instr, int idx) case QmlInstruction::AssignCustomType: qWarning() << idx << "\t" << line << "\t" << "ASSIGN_CUSTOMTYPE\t\t" << instr->assignCustomType.propertyIndex << "\t" << instr->assignCustomType.valueIndex; break; - case QmlInstruction::StoreBinding: - qWarning() << idx << "\t" << line << "\t" << "STORE_BINDING\t\t" << instr->assignBinding.property << "\t" << instr->assignBinding.value << "\t\t" << instr->assignBinding.context << primitives.at(instr->assignBinding.value); - break; case QmlInstruction::StoreCompiledBinding: qWarning() << idx << "\t" << line << "\t" << "STORE_COMPILED_BINDING\t" << instr->assignBinding.property << "\t" << instr->assignBinding.value << "\t\t" << instr->assignBinding.context; break; diff --git a/src/declarative/qml/qmlinstruction_p.h b/src/declarative/qml/qmlinstruction_p.h index c3d676f..e6b8de6 100644 --- a/src/declarative/qml/qmlinstruction_p.h +++ b/src/declarative/qml/qmlinstruction_p.h @@ -124,7 +124,6 @@ public: AssignSignalObject, /* assignSignalObject */ AssignCustomType, /* assignCustomType */ - StoreBinding, /* assignBinding */ StoreCompiledBinding, /* assignBinding */ StoreValueSource, /* assignValueSource */ diff --git a/src/declarative/qml/qmlvme.cpp b/src/declarative/qml/qmlvme.cpp index 7c02548..bf3b31a 100644 --- a/src/declarative/qml/qmlvme.cpp +++ b/src/declarative/qml/qmlvme.cpp @@ -549,28 +549,6 @@ QObject *QmlVME::run(QStack &stack, QmlContext *ctxt, QmlCompiledData } break; - case QmlInstruction::StoreBinding: - { - QObject *target = - stack.at(stack.count() - 1 - instr.assignBinding.owner); - QObject *context = - stack.at(stack.count() - 1 - instr.assignBinding.context); - - QmlMetaProperty mp; - mp.restore(instr.assignBinding.property, target, ctxt); - - QmlBinding *bind = new QmlBinding(primitives.at(instr.assignBinding.value), context, ctxt); - bindValues.append(bind); - QmlBindingPrivate *p = - static_cast(QObjectPrivate::get(bind)); - p->mePtr = &bindValues.values[bindValues.count - 1]; - QFx_setParent_noEvent(bind, target); - - bind->setTarget(mp); - bind->setSourceLocation(comp->url, instr.line); - } - break; - case QmlInstruction::StoreValueSource: { QmlPropertyValueSource *vs = -- cgit v0.12