aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@jollamobile.com>2014-08-09 22:01:08 +1000
committerRobin Burchell <robin.burchell@viroteck.net>2014-08-11 13:03:19 +0200
commit01c6af3fc940378e8eee41a9fb8273420ef5a7e1 (patch)
tree6cf3a1a4a060899837a75268654fa8ee9026a910
parente823bb5aee09c8a9f4a11bfd9ab6c68d2a77e93e (diff)
Avoid double deletion when deleting an incubating component.
The guard in QQmlIncubatorPrivate::clear() was invalidated by clearing the guards in QQmlIncubatorPrivate::incubate() when a deletion was detected. If we detect a deletion, leave the guards in place, to be handled in QQmlIncubatorPrivate::clear(). Task-number: QTBUG-40685 Change-Id: I1bf7422fda97745f1f7a3b42285a399244c09a1f Reviewed-by: Alan Alpert <aalpert@blackberry.com> Reviewed-by: Robin Burchell <robin.burchell@viroteck.net> Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
-rw-r--r--src/qml/qml/qqmlincubator.cpp7
-rw-r--r--tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp4
2 files changed, 3 insertions, 8 deletions
diff --git a/src/qml/qml/qqmlincubator.cpp b/src/qml/qml/qqmlincubator.cpp
index 4cdeb19719..098a664ded 100644
--- a/src/qml/qml/qqmlincubator.cpp
+++ b/src/qml/qml/qqmlincubator.cpp
@@ -292,10 +292,7 @@ void QQmlIncubatorPrivate::incubate(QQmlInstantiationInterrupt &i)
QQmlEngine *engine = compiledData->engine;
QQmlEnginePrivate *enginePriv = QQmlEnginePrivate::get(engine);
- bool guardOk = vmeGuard.isOK();
- vmeGuard.clear();
-
- if (!guardOk) {
+ if (!vmeGuard.isOK()) {
QQmlError error;
error.setUrl(compiledData->url);
error.setDescription(QQmlComponent::tr("Object destroyed during incubation"));
@@ -305,6 +302,8 @@ void QQmlIncubatorPrivate::incubate(QQmlInstantiationInterrupt &i)
goto finishIncubate;
}
+ vmeGuard.clear();
+
if (progress == QQmlIncubatorPrivate::Execute) {
enginePriv->referenceScarceResources();
QObject *tresult = 0;
diff --git a/tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp b/tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp
index 0b9872f94c..75b10ed804 100644
--- a/tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp
+++ b/tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp
@@ -171,10 +171,6 @@ void tst_qqmlincubator::objectDeleted()
controller.incubateWhile(&b);
}
- // We have to cheat and manually remove it from the creator->allCreatedObjects
- // otherwise we will do a double delete
- QQmlIncubatorPrivate *incubatorPriv = QQmlIncubatorPrivate::get(&incubator);
- incubatorPriv->creator->allCreatedObjects().pop();
delete SelfRegisteringType::me();
{