summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/qmlcontext.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative/qml/qmlcontext.cpp')
-rw-r--r--src/declarative/qml/qmlcontext.cpp34
1 files changed, 33 insertions, 1 deletions
diff --git a/src/declarative/qml/qmlcontext.cpp b/src/declarative/qml/qmlcontext.cpp
index 16399bc..df5f90e 100644
--- a/src/declarative/qml/qmlcontext.cpp
+++ b/src/declarative/qml/qmlcontext.cpp
@@ -86,6 +86,10 @@ void QmlContextPrivate::destroyed(QObject *obj)
void QmlContextPrivate::init()
{
Q_Q(QmlContext);
+
+ if (parent)
+ parent->d_func()->childContexts.insert(q);
+
//set scope chain
QScriptEngine *scriptEngine = engine->scriptEngine();
QScriptValue scopeObj =
@@ -232,7 +236,24 @@ QmlContext::QmlContext(QmlContext *parentContext, QObject *parent)
QmlContext::~QmlContext()
{
Q_D(QmlContext);
- for(int ii = 0; ii < d->contextObjects.count(); ++ii) {
+ if (d->parent)
+ d->parent->d_func()->childContexts.remove(this);
+
+ for (QSet<QmlContext *>::ConstIterator iter = d->childContexts.begin();
+ iter != d->childContexts.end();
+ ++iter) {
+ (*iter)->d_func()->invalidateEngines();
+ (*iter)->d_func()->parent = 0;
+ }
+
+ for (QSet<QmlExpression *>::ConstIterator iter =
+ d->childExpressions.begin();
+ iter != d->childExpressions.end();
+ ++iter) {
+ (*iter)->d->ctxt = 0;
+ }
+
+ for (int ii = 0; ii < d->contextObjects.count(); ++ii) {
QObjectPrivate *p = QObjectPrivate::get(d->contextObjects.at(ii));
QmlSimpleDeclarativeData *data =
static_cast<QmlSimpleDeclarativeData *>(p->declarativeData);
@@ -245,6 +266,17 @@ QmlContext::~QmlContext()
d->contextObjects.clear();
}
+void QmlContextPrivate::invalidateEngines()
+{
+ if (!engine)
+ return;
+ engine = 0;
+ for (QSet<QmlContext *>::ConstIterator iter = childContexts.begin();
+ iter != childContexts.end();
+ ++iter) {
+ (*iter)->d_func()->invalidateEngines();
+ }
+}
/*!
Return the context's QmlEngine, or 0 if the context has no QmlEngine or the