summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/qdeclarativeobjectscriptclass.cpp
diff options
context:
space:
mode:
authorWarwick Allison <warwick.allison@nokia.com>2010-04-19 05:57:54 (GMT)
committerWarwick Allison <warwick.allison@nokia.com>2010-04-19 06:33:09 (GMT)
commitb13def0486a083c48bae40dab2bac014b690f36d (patch)
treea6e21cd3846d7aff72ba619edec4c6e0652d93e1 /src/declarative/qml/qdeclarativeobjectscriptclass.cpp
parentfae16b674b619b73037841a00577de5922a26595 (diff)
downloadQt-b13def0486a083c48bae40dab2bac014b690f36d.zip
Qt-b13def0486a083c48bae40dab2bac014b690f36d.tar.gz
Qt-b13def0486a083c48bae40dab2bac014b690f36d.tar.bz2
List properties for dynamic meta objects.
Real solution is probably to fix/rewrite/dispose of QDeclarativeOpenMetaObject. Task-number: QTBUG-9420 Reviewed-by: Michael Brasser
Diffstat (limited to 'src/declarative/qml/qdeclarativeobjectscriptclass.cpp')
-rw-r--r--src/declarative/qml/qdeclarativeobjectscriptclass.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp
index a27d19d..a194354 100644
--- a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp
+++ b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp
@@ -463,12 +463,21 @@ QStringList QDeclarativeObjectScriptClass::propertyNames(Object *object)
cache = ddata->propertyCache;
if (!cache) {
cache = enginePrivate->cache(obj);
- if (cache && ddata) { cache->addref(); ddata->propertyCache = cache; }
+ if (cache) {
+ if (ddata) { cache->addref(); ddata->propertyCache = cache; }
+ } else {
+ // Not cachable - fall back to QMetaObject (eg. dynamic meta object)
+ // XXX QDeclarativeOpenMetaObject has a cache, so this is suboptimal.
+ // XXX This is a workaround for QTBUG-9420.
+ const QMetaObject *mo = obj->metaObject();
+ QStringList r;
+ int pc = mo->propertyCount();
+ int po = mo->propertyOffset();
+ for (int i=po; i<pc; ++i)
+ r += QString::fromUtf8(mo->property(i).name());
+ return r;
+ }
}
-
- if (!cache)
- return QStringList();
-
return cache->propertyNames();
}