summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/qmlengine.cpp
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2009-11-16 01:53:49 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2009-11-16 01:53:49 (GMT)
commit48738dd945f8eb3112ce295c37a67632121020e7 (patch)
treea18e4370fde60752ec55551ffff583d3fd83fdfc /src/declarative/qml/qmlengine.cpp
parenta720cb9fc573edd77a559be31bb2dcc090faf1aa (diff)
downloadQt-48738dd945f8eb3112ce295c37a67632121020e7.zip
Qt-48738dd945f8eb3112ce295c37a67632121020e7.tar.gz
Qt-48738dd945f8eb3112ce295c37a67632121020e7.tar.bz2
QmlEngine tests
Diffstat (limited to 'src/declarative/qml/qmlengine.cpp')
-rw-r--r--src/declarative/qml/qmlengine.cpp16
1 files changed, 5 insertions, 11 deletions
diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp
index b6f3bde..66d4990 100644
--- a/src/declarative/qml/qmlengine.cpp
+++ b/src/declarative/qml/qmlengine.cpp
@@ -427,22 +427,16 @@ QmlContext *QmlEngine::contextForObject(const QObject *object)
*/
void QmlEngine::setContextForObject(QObject *object, QmlContext *context)
{
- QObjectPrivate *priv = QObjectPrivate::get(object);
-
- QmlDeclarativeData *data =
- static_cast<QmlDeclarativeData *>(priv->declarativeData);
+ if (!object || !context)
+ return;
- if (data && data->context) {
+ QmlDeclarativeData *data = QmlDeclarativeData::get(object, true);
+ if (data->context) {
qWarning("QmlEngine::setContextForObject(): Object already has a QmlContext");
return;
}
- if (!data) {
- priv->declarativeData = new QmlDeclarativeData(context);
- } else {
- data->context = context;
- }
-
+ data->context = context;
context->d_func()->contextObjects.append(object);
}