diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-02-11 04:52:34 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-02-12 04:58:22 (GMT) |
commit | 1d2b1b31166e029e009f08877ef95f95e58a03a4 (patch) | |
tree | ae2ce1a9465f885ff6e24b583fe7330c74a9dd78 /src/declarative/qml/qmlcontext.cpp | |
parent | 4b740bdf8cbaaf97541a821c28bae075067343d3 (diff) | |
download | Qt-1d2b1b31166e029e009f08877ef95f95e58a03a4.zip Qt-1d2b1b31166e029e009f08877ef95f95e58a03a4.tar.gz Qt-1d2b1b31166e029e009f08877ef95f95e58a03a4.tar.bz2 |
Cleanup public QmlMetaType API
Remove some unnecessary methods from the QmlMetaType class
Diffstat (limited to 'src/declarative/qml/qmlcontext.cpp')
-rw-r--r-- | src/declarative/qml/qmlcontext.cpp | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/src/declarative/qml/qmlcontext.cpp b/src/declarative/qml/qmlcontext.cpp index 4c6dc6f..d9fc76b 100644 --- a/src/declarative/qml/qmlcontext.cpp +++ b/src/declarative/qml/qmlcontext.cpp @@ -383,23 +383,26 @@ void QmlContext::setContextProperty(const QString &name, const QVariant &value) if (d->notifyIndex == -1) d->notifyIndex = this->metaObject()->methodCount(); - if (d->engine && QmlEnginePrivate::get(d->engine)->isObject(value.userType())) { - QObject *o = *(QObject **)value.constData(); - setContextProperty(name, o); - } else { + if (d->engine) { + bool ok; + QObject *o = QmlEnginePrivate::get(d->engine)->toQObject(value, &ok); + if (ok) { + setContextProperty(name, o); + return; + } + } - if (!d->propertyNames) d->propertyNames = new QmlIntegerCache(d->engine); + if (!d->propertyNames) d->propertyNames = new QmlIntegerCache(d->engine); - int idx = d->propertyNames->value(name); - if (idx == -1) { - d->propertyNames->add(name, d->idValueCount + d->propertyValues.count()); - d->propertyValues.append(value); + int idx = d->propertyNames->value(name); + if (idx == -1) { + d->propertyNames->add(name, d->idValueCount + d->propertyValues.count()); + d->propertyValues.append(value); - d->refreshExpressions(); - } else { - d->propertyValues[idx] = value; - QMetaObject::activate(this, idx + d->notifyIndex, 0); - } + d->refreshExpressions(); + } else { + d->propertyValues[idx] = value; + QMetaObject::activate(this, idx + d->notifyIndex, 0); } } |