diff options
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/qml/qqmlnotifier/data/objectRenamer.qml | 9 | ||||
-rw-r--r-- | tests/auto/qml/qqmlnotifier/tst_qqmlnotifier.cpp | 32 |
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" |