aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlnotifier
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2019-01-14 17:07:38 +0100
committerUlf Hermann <ulf.hermann@qt.io>2019-01-23 07:43:31 +0000
commitfeb9ace3de30170f785217fdb7c454e92ca6d525 (patch)
tree9ab5b0190944fffdb0f9eba04aa6b4200c7d6135 /tests/auto/qml/qqmlnotifier
parent8380e4c4a4f3f49a74a8bc0ff330e1c9e14dbafc (diff)
QQmlNotifier: Always keep the isNotifying flag when updating senderPtr
When the sender gets deleted we still want to retain the flag that tells us that the notifier is currently active. Otherwise we can miss the error message about synchronously deleting objects while signal handlers are in progress. Task-number: QTBUG-73013 Change-Id: I8abba9b492327c15963d1875841c6822f345a89e Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmlnotifier')
-rw-r--r--tests/auto/qml/qqmlnotifier/data/objectRenamer.qml9
-rw-r--r--tests/auto/qml/qqmlnotifier/tst_qqmlnotifier.cpp32
2 files changed, 41 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlnotifier/data/objectRenamer.qml b/tests/auto/qml/qqmlnotifier/data/objectRenamer.qml
new file mode 100644
index 0000000000..65d2206880
--- /dev/null
+++ b/tests/auto/qml/qqmlnotifier/data/objectRenamer.qml
@@ -0,0 +1,9 @@
+import QtQml 2.2
+
+QtObject {
+ property Timer timer: Timer {
+ running: true
+ interval: 0
+ onTriggered: parent.objectName = "havoc"
+ }
+}
diff --git a/tests/auto/qml/qqmlnotifier/tst_qqmlnotifier.cpp b/tests/auto/qml/qqmlnotifier/tst_qqmlnotifier.cpp
index 8811f779bb..6e831eacc1 100644
--- a/tests/auto/qml/qqmlnotifier/tst_qqmlnotifier.cpp
+++ b/tests/auto/qml/qqmlnotifier/tst_qqmlnotifier.cpp
@@ -32,6 +32,9 @@
#include <QQmlContext>
#include <qqml.h>
#include <QMetaMethod>
+#if QT_CONFIG(process)
+#include <QProcess>
+#endif
#include "../../shared/util.h"
@@ -156,6 +159,8 @@ private slots:
void disconnectOnDestroy();
void lotsOfBindings();
+ void deleteFromHandler();
+
private:
void createObjects();
@@ -335,6 +340,33 @@ void tst_qqmlnotifier::lotsOfBindings()
delete e;
}
+void tst_qqmlnotifier::deleteFromHandler()
+{
+#if !QT_CONFIG(process)
+ QSKIP("Need QProcess support to test qFatal.");
+#else
+ if (qEnvironmentVariableIsSet("TST_QQMLNOTIFIER_DO_CRASH")) {
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("objectRenamer.qml"));
+ QPointer<QObject> mess = component.create();
+ QObject::connect(mess, &QObject::objectNameChanged, [&]() { delete mess; });
+ QTRY_VERIFY(mess.isNull()); // BANG!
+ } else {
+ QProcess process;
+ QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
+ env.insert("TST_QQMLNOTIFIER_DO_CRASH", "bang");
+ process.setProcessEnvironment(env);
+ process.setProgram(QCoreApplication::applicationFilePath());
+ process.setArguments({"deleteFromHandler"});
+ process.start();
+ QTRY_COMPARE(process.exitStatus(), QProcess::CrashExit);
+ const QByteArray output = process.readAllStandardOutput();
+ QVERIFY(output.contains("QFATAL"));
+ QVERIFY(output.contains("destroyed while one of its QML signal handlers is in progress"));
+ }
+#endif
+}
+
QTEST_MAIN(tst_qqmlnotifier)
#include "tst_qqmlnotifier.moc"