aboutsummaryrefslogtreecommitdiffstats
path: root/src/imports
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2016-12-15 15:38:29 +0100
committerMitch Curtis <mitch.curtis@qt.io>2016-12-21 14:09:32 +0000
commitfd0c4fb24a58b4acaba613dc83634f28dfdbfeda (patch)
tree7e61fac4a79b5bee223bb6d9efc8ca3d5fc07840 /src/imports
parentc4eefa4a8d6d3e95062deb78229940460a7ef605 (diff)
TestCase: don't try to access destroyed temporary objects
Objects created with createTemporaryObject() and createTemporaryQmlObject() can be destroyed manually before the test ends. Before this patch, there would be a type error when trying to check if the object still exists in qtest_destroyTemporaryObjects(). The error seems to stem from the fact that objects that are stored in an array and later destroy()'d are not nullified, but rather left in a corrupt state. See the linked bug for more information about this. We work around this issue by checking for the existence of the destroy() function on the object before attempting to call it. Task-number: QTBUG-57749 Change-Id: I0f6ddd47d86af6fb87392c2992f9f6143af6aab8 Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
Diffstat (limited to 'src/imports')
-rw-r--r--src/imports/testlib/TestCase.qml3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/imports/testlib/TestCase.qml b/src/imports/testlib/TestCase.qml
index ad7533c550..1ead2f21b7 100644
--- a/src/imports/testlib/TestCase.qml
+++ b/src/imports/testlib/TestCase.qml
@@ -614,7 +614,8 @@ Item {
function qtest_destroyTemporaryObjects() {
for (var i = 0; i < qtest_temporaryObjects.length; ++i) {
var temporaryObject = qtest_temporaryObjects[i];
- if (temporaryObject)
+ // ### the typeof check can be removed when QTBUG-57749 is fixed
+ if (temporaryObject && typeof temporaryObject.destroy === "function")
temporaryObject.destroy();
}
qtest_temporaryObjects = [];