From c8cc4f162df71a6103af06e783c0e0eab4c67fdc Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 10 Jul 2013 09:52:03 +0200 Subject: QTestlib: Re-enable Windows error dialog when -nocrashhandler is passed. The error dialog is sometimes desired when trying to attach a debugger. Use the -nocrashhandler option for it, which already exists on UNIX. Change-Id: I42c9311242cdeaa81a148af9bf61875e1bc6f32c Reviewed-by: Simon Hausmann --- src/testlib/doc/src/qttestlib-manual.qdoc | 3 +++ src/testlib/qtestcase.cpp | 22 +++++++++------------- 2 files changed, 12 insertions(+), 13 deletions(-) (limited to 'src/testlib') diff --git a/src/testlib/doc/src/qttestlib-manual.qdoc b/src/testlib/doc/src/qttestlib-manual.qdoc index c44bb49ae3..613d2c220c 100644 --- a/src/testlib/doc/src/qttestlib-manual.qdoc +++ b/src/testlib/doc/src/qttestlib-manual.qdoc @@ -247,6 +247,9 @@ 2000. \li \c -nocrashhandler \br Disables the crash handler on Unix platforms. + On Windows, it re-enables the Windows Error Reporting dialog, which is + turned off by default. + \li \c -platform \e name \br This command line argument applies to all Qt applications, but might be especially useful in the context of auto-testing. By using the "offscreen" diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index 77a59d0cf0..2e1adb8a20 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -1130,9 +1130,7 @@ namespace QTest static int keyDelay = -1; static int mouseDelay = -1; static int eventDelay = -1; -#if defined(Q_OS_UNIX) static bool noCrashHandler = false; -#endif /*! \internal Invoke a method of the object without generating warning if the method does not exist @@ -1335,9 +1333,7 @@ Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml) " -mousedelay ms : Set default delay for mouse simulation to ms milliseconds\n" " -maxwarnings n : Sets the maximum amount of messages to output.\n" " 0 means unlimited, default: 2000\n" -#if defined(Q_OS_UNIX) " -nocrashhandler : Disables the crash handler\n" -#endif "\n" " Benchmarking options:\n" #ifdef QTESTLIB_USE_VALGRIND @@ -1468,10 +1464,8 @@ Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml) } else { QTestLog::setMaxWarnings(qToInt(argv[++i])); } -#if defined(Q_OS_UNIX) } else if (strcmp(argv[i], "-nocrashhandler") == 0) { QTest::noCrashHandler = true; -#endif #ifdef QTESTLIB_USE_VALGRIND } else if (strcmp(argv[i], "-callgrind") == 0) { if (QBenchmarkValgrindUtils::haveValgrind()) @@ -2138,13 +2132,6 @@ int QTest::qExec(QObject *testObject, int argc, char **argv) try { #endif -#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) -# if !defined(Q_CC_MINGW) - _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG); -# endif - SetErrorMode(SetErrorMode(0) | SEM_NOGPFAULTERRORBOX); -#endif - #if defined(Q_OS_MACX) if (macNeedsActivate) { CFStringRef reasonForActivity= CFSTR("No Display Sleep"); @@ -2170,6 +2157,15 @@ int QTest::qExec(QObject *testObject, int argc, char **argv) qtest_qParseArgs(argc, argv, false); +#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) + if (!noCrashHandler) { +# ifndef Q_CC_MINGW + _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG); +# endif + SetErrorMode(SetErrorMode(0) | SEM_NOGPFAULTERRORBOX); + } // !noCrashHandler +#endif // Q_OS_WIN) && !Q_OS_WINCE + #ifdef QTESTLIB_USE_VALGRIND if (QBenchmarkGlobalData::current->mode() == QBenchmarkGlobalData::CallgrindParentProcess) { const QStringList origAppArgs(QCoreApplication::arguments()); -- cgit v1.2.3