QtTest: Don't crash when -callgrind is used on QTEST_APPLESS_MAIN

If there's no qApp, then QCoreApplication::arguments() returns an empty
list (after printing a warning). That means the callgrind runner can't
get the arguments it needs in order to rerun the benchmark.

The crash happens because it always uses .at(0) to try and get the
executable's path. Even if we get the path from somewhere else, we still
need the arguments.

Change-Id: I5c74af4d96fc5824b2b7fd7a89648d78393016e2
Reviewed-by: Sergio Ahumada <sahumada@blackberry.com>
This commit is contained in:
Thiago Macieira 2014-02-21 19:02:45 -08:00 committed by The Qt Project
parent 12a7d23d52
commit e85b4ed77a

View File

@ -2442,6 +2442,9 @@ int QTest::qExec(QObject *testObject, int argc, char **argv)
#ifdef QTESTLIB_USE_VALGRIND
if (QBenchmarkGlobalData::current->mode() == QBenchmarkGlobalData::CallgrindParentProcess) {
if (!qApp)
qFatal("QtTest: -callgrind option is not available with QTEST_APPLESS_MAIN");
const QStringList origAppArgs(QCoreApplication::arguments());
if (!QBenchmarkValgrindUtils::rerunThroughCallgrind(origAppArgs, callgrindChildExitCode))
return -1;