aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmltest
diff options
context:
space:
mode:
authorRainer Keller <Rainer.Keller@qt.io>2018-09-20 10:51:18 +0200
committerRainer Keller <Rainer.Keller@qt.io>2018-09-24 06:10:27 +0000
commit7bf8d4d3772959f06d4dd0168af7774adde29d76 (patch)
treedc4fa13dd572a4cb7224fb680d36761d5985ff9f /src/qmltest
parent6146021eb72a0aca5cc635b577b5e43b60824bc8 (diff)
Add test cleanup function for C++ parts
This allows to do cleanup in C++ before other parts being destructed. It QtOpcUa we need to destruct a subprocess. Until now it was done in the destructor of the setup class. When the destructor is called the eventloop already died but the process is still sending output when being terminated. In the windows event handling a nullptr is being dereferenced in this case, see QTBUG-70641. When terminating this process somewhat earlier, when the eventloop is still available, the event dispatcher is able to handle those events without crashing. Another reason to have this function is because there is applicationAvailable() being called to initialize C++ code and there should be an equivalent function for cleaning up. [ChangeLog][QtQml][QtTest] Add cleanupTestCase() to be called before starting destruction Change-Id: I24f7a51ec5276a449892609f5b2cfe7957c27668 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/qmltest')
-rw-r--r--src/qmltest/doc/src/qtquicktest-index.qdoc3
-rw-r--r--src/qmltest/quicktest.cpp5
2 files changed, 8 insertions, 0 deletions
diff --git a/src/qmltest/doc/src/qtquicktest-index.qdoc b/src/qmltest/doc/src/qtquicktest-index.qdoc
index f641d8248f..700bddc8d5 100644
--- a/src/qmltest/doc/src/qtquicktest-index.qdoc
+++ b/src/qmltest/doc/src/qtquicktest-index.qdoc
@@ -157,6 +157,9 @@
\l {QQmlEngine::addPluginPath}{plugin paths},
and \l {QQmlFileSelector::setExtraSelectors}{extra file selectors}
will have been set on the engine by this point.
+ \li void cleanupTestCase()
+ \li Called right after the test execution has finished.
+ Use this function to clean up before everything will start to be destructed.
\endtable
Each function will be called once for each \c tst_*.qml file, so any
diff --git a/src/qmltest/quicktest.cpp b/src/qmltest/quicktest.cpp
index f2d5848d54..f666bc2284 100644
--- a/src/qmltest/quicktest.cpp
+++ b/src/qmltest/quicktest.cpp
@@ -588,6 +588,11 @@ int quick_test_main_with_setup(int argc, char **argv, const char *name, const ch
}
}
+ if (setup) {
+ // Don't check the return value; it's OK if it doesn't exist.
+ QMetaObject::invokeMethod(setup, "cleanupTestCase");
+ }
+
// Flush the current logging stream.
QuickTestResult::setProgramName(nullptr);
delete app;