summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2009-07-16 01:45:33 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2009-07-16 01:49:51 (GMT)
commit84637da766fe1e3a4b4240601a6002f94f1b07c9 (patch)
treebbd323842d7daa8bf17f0183d455b439a1c092a4 /src
parentbefae051c1f80d66f459f375279f36047017c194 (diff)
downloadQt-84637da766fe1e3a4b4240601a6002f94f1b07c9.zip
Qt-84637da766fe1e3a4b4240601a6002f94f1b07c9.tar.gz
Qt-84637da766fe1e3a4b4240601a6002f94f1b07c9.tar.bz2
Fix crash on object destruction
Diffstat (limited to 'src')
-rw-r--r--src/declarative/qml/qmlbasicscript.cpp9
-rw-r--r--src/declarative/qml/qmlcontext.cpp11
2 files changed, 15 insertions, 5 deletions
diff --git a/src/declarative/qml/qmlbasicscript.cpp b/src/declarative/qml/qmlbasicscript.cpp
index 478491f..d6d6625 100644
--- a/src/declarative/qml/qmlbasicscript.cpp
+++ b/src/declarative/qml/qmlbasicscript.cpp
@@ -181,6 +181,9 @@ static QVariant toObjectOrVariant(const QVariant &v)
static QVariant fetch_value(QObject *o, int idx, int type)
{
+ if (!o)
+ return QVariant();
+
switch(type) {
case QVariant::String:
{
@@ -823,7 +826,7 @@ QVariant QmlBasicScript::run(QmlContext *context, void *voidCache, CacheState *c
QObject *obj = contextPrivate->defaultObjects.at(0);
stack.push(fetch_value(obj, instr.constant.idx, instr.constant.type));
- if (instr.constant.notify != 0)
+ if (obj && instr.constant.notify != 0)
enginePrivate->capturedProperties <<
QmlEnginePrivate::CapturedProperty(obj, instr.constant.idx, instr.constant.notify);
state = Reset;
@@ -835,7 +838,7 @@ QVariant QmlBasicScript::run(QmlContext *context, void *voidCache, CacheState *c
QObject *obj = contextPrivate->defaultObjects.at(1);
stack.push(fetch_value(obj, instr.constant.idx, instr.constant.type));
- if (instr.constant.notify != 0)
+ if (obj && instr.constant.notify != 0)
enginePrivate->capturedProperties <<
QmlEnginePrivate::CapturedProperty(obj, instr.constant.idx, instr.constant.notify);
state = Reset;
@@ -848,7 +851,7 @@ QVariant QmlBasicScript::run(QmlContext *context, void *voidCache, CacheState *c
QObject *obj = qvariant_cast<QObject *>(o);
stack.push(fetch_value(obj, instr.constant.idx, instr.constant.type));
- if (instr.constant.notify != 0)
+ if (obj && instr.constant.notify != 0)
enginePrivate->capturedProperties <<
QmlEnginePrivate::CapturedProperty(obj, instr.constant.idx, instr.constant.notify);
state = Reset;
diff --git a/src/declarative/qml/qmlcontext.cpp b/src/declarative/qml/qmlcontext.cpp
index b605869..440f4b8 100644
--- a/src/declarative/qml/qmlcontext.cpp
+++ b/src/declarative/qml/qmlcontext.cpp
@@ -86,8 +86,15 @@ void QmlContextPrivate::destroyed(QObject *obj)
}
}
- for (int ii = 0; ii < notifies.count(); ++ii) {
- QMetaObject::activate(q, notifies[ii] + notifyIndex, 0);
+ // There is no need to emit these notifications if our parent is in the
+ // process of being deleted (which is *probably* why obj has been destroyed
+ // anyway), as we're about to get deleted which will invalidate all the
+ // expressions that could depend on us
+ QObject *parent = q->parent();
+ if (!parent || !QObjectPrivate::get(parent)->wasDeleted) {
+ for (int ii = 0; ii < notifies.count(); ++ii) {
+ QMetaObject::activate(q, notifies[ii] + notifyIndex, 0);
+ }
}
}