summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorYann Bodson <yann.bodson@nokia.com>2010-02-08 05:31:17 (GMT)
committerYann Bodson <yann.bodson@nokia.com>2010-02-08 05:31:17 (GMT)
commitfd2463dcde5d921bccdbaddf25e33574affbd41f (patch)
treed4e6c42e937adf4adc631d1269dbdb96ea896de6 /src
parent2fd36a6320aed7c2f825c2c38f2ef6d0b2703e17 (diff)
parent1ab17b479a41559c74c86916492bb812c0b9e74e (diff)
downloadQt-fd2463dcde5d921bccdbaddf25e33574affbd41f.zip
Qt-fd2463dcde5d921bccdbaddf25e33574affbd41f.tar.gz
Qt-fd2463dcde5d921bccdbaddf25e33574affbd41f.tar.bz2
Merge branch 'master' of scm.dev.nokia.troll.no:qt/qt-qml
Diffstat (limited to 'src')
-rw-r--r--src/declarative/qml/qmlcompiledbindings.cpp33
-rw-r--r--src/declarative/qml/qmlcontext.cpp15
-rw-r--r--src/declarative/qml/qmlengine_p.h1
-rw-r--r--src/declarative/qml/qmlmetaproperty.cpp23
-rw-r--r--src/declarative/qml/qmlobjectscriptclass.cpp18
-rw-r--r--src/declarative/qml/qmlpropertycache.cpp60
-rw-r--r--src/declarative/qml/qmlpropertycache_p.h8
7 files changed, 83 insertions, 75 deletions
diff --git a/src/declarative/qml/qmlcompiledbindings.cpp b/src/declarative/qml/qmlcompiledbindings.cpp
index d09f7eb..cdea96f 100644
--- a/src/declarative/qml/qmlcompiledbindings.cpp
+++ b/src/declarative/qml/qmlcompiledbindings.cpp
@@ -807,36 +807,6 @@ static QObject *variantToQObject(const QVariant &value, bool *ok)
}
}
-QmlPropertyCache::Data *
-QmlCompiledBindingsPrivate::findproperty(QObject *obj,
- const QScriptDeclarativeClass::Identifier &name,
- QmlEnginePrivate *enginePriv,
- QmlPropertyCache::Data &local)
-{
- QmlPropertyCache *cache = 0;
- QmlDeclarativeData *ddata = QmlDeclarativeData::get(obj);
- if (ddata)
- cache = ddata->propertyCache;
- if (!cache) {
- cache = enginePriv->cache(obj);
- if (cache && ddata) { cache->addref(); ddata->propertyCache = cache; }
- }
-
- QmlPropertyCache::Data *property = 0;
-
- if (cache) {
- property = cache->property(name);
- } else {
- qWarning() << "QmlBindingVME: Slow search" << enginePriv->objectClass->toString(name);
- local = QmlPropertyCache::create(obj->metaObject(),
- enginePriv->objectClass->toString(name));
- if (local.isValid())
- property = &local;
- }
-
- return property;
-}
-
bool QmlCompiledBindingsPrivate::findproperty(QObject *obj, Register *output,
QmlEnginePrivate *enginePriv,
int subIdx, const QScriptDeclarativeClass::Identifier &name,
@@ -848,7 +818,8 @@ bool QmlCompiledBindingsPrivate::findproperty(QObject *obj, Register *output,
}
QmlPropertyCache::Data local;
- QmlPropertyCache::Data *property = findproperty(obj, name, enginePriv, local);
+ QmlPropertyCache::Data *property =
+ QmlPropertyCache::property(QmlEnginePrivate::get(enginePriv), obj, name, local);
if (property) {
if (subIdx != -1)
diff --git a/src/declarative/qml/qmlcontext.cpp b/src/declarative/qml/qmlcontext.cpp
index 0eb497d..4c6dc6f 100644
--- a/src/declarative/qml/qmlcontext.cpp
+++ b/src/declarative/qml/qmlcontext.cpp
@@ -461,16 +461,13 @@ QVariant QmlContext::contextProperty(const QString &name) const
QByteArray utf8Name = name.toUtf8();
for (int ii = d->defaultObjects.count() - 1; ii >= 0; --ii) {
QObject *obj = d->defaultObjects.at(ii);
- QmlDeclarativeData *data = QmlDeclarativeData::get(obj);
- if (data && data->propertyCache) {
- QmlPropertyCache::Data *property = data->propertyCache->property(name);
- if (property)
- value = obj->metaObject()->property(property->coreIndex).read(obj);
- } else {
- value = obj->property(utf8Name);
- }
- if (value.isValid())
+ QmlPropertyCache::Data local;
+ QmlPropertyCache::Data *property = QmlPropertyCache::property(d->engine, obj, name, local);
+
+ if (property) {
+ value = obj->metaObject()->property(property->coreIndex).read(obj);
break;
+ }
}
if (!value.isValid() && parentContext())
value = parentContext()->contextProperty(name);
diff --git a/src/declarative/qml/qmlengine_p.h b/src/declarative/qml/qmlengine_p.h
index 6aa5d69..8349090 100644
--- a/src/declarative/qml/qmlengine_p.h
+++ b/src/declarative/qml/qmlengine_p.h
@@ -309,6 +309,7 @@ public:
static QmlEngine *getEngine(QScriptEngine *e) { return static_cast<QmlScriptEngine*>(e)->p->q_func(); }
static QmlEnginePrivate *get(QmlEngine *e) { return e->d_func(); }
static QmlEnginePrivate *get(QScriptEngine *e) { return static_cast<QmlScriptEngine*>(e)->p; }
+ static QmlEngine *get(QmlEnginePrivate *p) { return p->q_func(); }
QmlContext *getContext(QScriptContext *);
};
diff --git a/src/declarative/qml/qmlmetaproperty.cpp b/src/declarative/qml/qmlmetaproperty.cpp
index 0603a9c..09c936e 100644
--- a/src/declarative/qml/qmlmetaproperty.cpp
+++ b/src/declarative/qml/qmlmetaproperty.cpp
@@ -188,24 +188,11 @@ void QmlMetaPropertyPrivate::initProperty(QObject *obj, const QString &name)
}
// Property
- QmlPropertyCache *cache = 0;
- QmlDeclarativeData *ddata = QmlDeclarativeData::get(obj);
- if (ddata)
- cache = ddata->propertyCache;
- if (!cache)
- cache = enginePrivate?enginePrivate->cache(obj):0;
-
- if (cache) {
- QmlPropertyCache::Data *data = cache->property(name);
-
- if (data && !(data->flags & QmlPropertyCache::Data::IsFunction))
- core = *data;
-
- } else {
- // No cache available
- QMetaProperty p = QmlMetaType::property(obj, name.toUtf8().constData());
- core.load(p);
- }
+ QmlPropertyCache::Data local;
+ QmlPropertyCache::Data *property =
+ QmlPropertyCache::property(context?context->engine():0, obj, name, local);
+ if (property && !(property->flags & QmlPropertyCache::Data::IsFunction))
+ core = *property;
}
/*!
diff --git a/src/declarative/qml/qmlobjectscriptclass.cpp b/src/declarative/qml/qmlobjectscriptclass.cpp
index 4ff4746..7bbb7df 100644
--- a/src/declarative/qml/qmlobjectscriptclass.cpp
+++ b/src/declarative/qml/qmlobjectscriptclass.cpp
@@ -144,23 +144,7 @@ QmlObjectScriptClass::queryProperty(QObject *obj, const Identifier &name,
return 0;
QmlEnginePrivate *enginePrivate = QmlEnginePrivate::get(engine);
-
- QmlPropertyCache *cache = 0;
- QmlDeclarativeData *ddata = QmlDeclarativeData::get(obj);
- if (ddata)
- cache = ddata->propertyCache;
- if (!cache) {
- cache = enginePrivate->cache(obj);
- if (cache && ddata) { cache->addref(); ddata->propertyCache = cache; }
- }
-
- if (cache) {
- lastData = cache->property(name);
- } else {
- local = QmlPropertyCache::create(obj->metaObject(), toString(name));
- if (local.isValid())
- lastData = &local;
- }
+ lastData = QmlPropertyCache::property(engine, obj, name, local);
if (lastData)
return QScriptClass::HandlesReadAccess | QScriptClass::HandlesWriteAccess;
diff --git a/src/declarative/qml/qmlpropertycache.cpp b/src/declarative/qml/qmlpropertycache.cpp
index 51753b8..04cffe1 100644
--- a/src/declarative/qml/qmlpropertycache.cpp
+++ b/src/declarative/qml/qmlpropertycache.cpp
@@ -352,4 +352,64 @@ QStringList QmlPropertyCache::propertyNames() const
return stringCache.keys();
}
+QmlPropertyCache::Data *QmlPropertyCache::property(QmlEngine *engine, QObject *obj,
+ const QScriptDeclarativeClass::Identifier &name, Data &local)
+{
+ QmlPropertyCache::Data *rv = 0;
+
+ QmlEnginePrivate *enginePrivate = QmlEnginePrivate::get(engine);
+
+ QmlPropertyCache *cache = 0;
+ QmlDeclarativeData *ddata = QmlDeclarativeData::get(obj);
+ if (ddata && ddata->propertyCache && ddata->propertyCache->qmlEngine() == engine)
+ cache = ddata->propertyCache;
+ if (!cache) {
+ cache = enginePrivate->cache(obj);
+ if (cache && ddata && !ddata->propertyCache) { cache->addref(); ddata->propertyCache = cache; }
+ }
+
+ if (cache) {
+ rv = cache->property(name);
+ } else {
+ local = QmlPropertyCache::create(obj->metaObject(), enginePrivate->objectClass->toString(name));
+ if (local.isValid())
+ rv = &local;
+ }
+
+ return rv;
+}
+
+QmlPropertyCache::Data *QmlPropertyCache::property(QmlEngine *engine, QObject *obj,
+ const QString &name, Data &local)
+{
+ QmlPropertyCache::Data *rv = 0;
+
+ if (!engine) {
+ local = QmlPropertyCache::create(obj->metaObject(), name);
+ if (local.isValid())
+ rv = &local;
+ } else {
+ QmlEnginePrivate *enginePrivate = QmlEnginePrivate::get(engine);
+
+ QmlPropertyCache *cache = 0;
+ QmlDeclarativeData *ddata = QmlDeclarativeData::get(obj);
+ if (ddata && ddata->propertyCache && ddata->propertyCache->qmlEngine() == engine)
+ cache = ddata->propertyCache;
+ if (!cache) {
+ cache = enginePrivate->cache(obj);
+ if (cache && ddata && !ddata->propertyCache) { cache->addref(); ddata->propertyCache = cache; }
+ }
+
+ if (cache) {
+ rv = cache->property(name);
+ } else {
+ local = QmlPropertyCache::create(obj->metaObject(), name);
+ if (local.isValid())
+ rv = &local;
+ }
+ }
+
+ return rv;
+}
+
QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmlpropertycache_p.h b/src/declarative/qml/qmlpropertycache_p.h
index 8d54e35..efc4643 100644
--- a/src/declarative/qml/qmlpropertycache_p.h
+++ b/src/declarative/qml/qmlpropertycache_p.h
@@ -132,6 +132,9 @@ public:
Data *property(int) const;
QStringList propertyNames() const;
+ inline QmlEngine *qmlEngine() const;
+ static Data *property(QmlEngine *, QObject *, const QScriptDeclarativeClass::Identifier &, Data &);
+ static Data *property(QmlEngine *, QObject *, const QString &, Data &);
protected:
virtual void clear();
@@ -181,6 +184,11 @@ bool QmlPropertyCache::ValueTypeData::operator==(const ValueTypeData &o)
valueTypePropType == o.valueTypePropType;
}
+QmlEngine *QmlPropertyCache::qmlEngine() const
+{
+ return engine;
+}
+
QT_END_NAMESPACE
#endif // QMLPROPERTYCACHE_P_H