From abc4cdb4c0d1b234ea9507c3f88db82311d12389 Mon Sep 17 00:00:00 2001 From: Florent Rougon Date: Thu, 29 Mar 2018 00:39:38 +0200 Subject: [PATCH] TestSuite: call flightgear::shutdownQtApp() from fgtest::shutdownTestGlobals() Some of the unit tests defined with the new test infrastructure[1] initialize the QApplication; for these tests, it is necessary to ensure that the QApplication instance is destroyed before exit() begins, otherwise we get a segfault when run_test_suite terminates (see [2]). In order to prevent this segfault from happening, call flightgear::shutdownQtApp() unconditionally from fgtest::shutdownTestGlobals() as long as Qt support is compiled in (flightgear::shutdownQtApp() is safe to call even if the QApplication hasn't been initialized). [1] Currently, the three PosInitTests::* tests. [2] https://bugreports.qt.io/browse/QTBUG-48709 --- test_suite/helpers/globals.cxx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test_suite/helpers/globals.cxx b/test_suite/helpers/globals.cxx index 5cb52824d..8d3aea0f9 100644 --- a/test_suite/helpers/globals.cxx +++ b/test_suite/helpers/globals.cxx @@ -3,6 +3,10 @@ #include "globals.hxx" +#if defined(HAVE_QT) +#include +#endif + #include
#include
@@ -93,6 +97,12 @@ namespace fgtest void shutdownTestGlobals() { + // The QApplication instance must be destroyed before exit() begins, see + // (otherwise, segfault). +#if defined(HAVE_QT) + flightgear::shutdownQtApp(); +#endif + delete globals; } } // of namespace fgtest