Testlib: Add a crash handler for Windows that prints a message.
Change-Id: I4d6559fd1b21f9f259be6a5a160361e25ea0d217 Reviewed-by: Jason McDonald <macadder1@gmail.com>
This commit is contained in:
parent
915f4d8c95
commit
066d32d743
@ -2077,6 +2077,18 @@ FatalSignalHandler::~FatalSignalHandler()
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
|
||||||
|
static LONG WINAPI windowsFaultHandler(struct _EXCEPTION_POINTERS *exInfo)
|
||||||
|
{
|
||||||
|
char appName[MAX_PATH];
|
||||||
|
if (!GetModuleFileNameA(NULL, appName, MAX_PATH))
|
||||||
|
appName[0] = 0;
|
||||||
|
fprintf(stderr, "A crash occurred in %s (exception code 0x%lx).",
|
||||||
|
appName, exInfo->ExceptionRecord->ExceptionCode);
|
||||||
|
return EXCEPTION_EXECUTE_HANDLER;
|
||||||
|
}
|
||||||
|
#endif // Q_OS_WIN) && !Q_OS_WINCE
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Executes tests declared in \a testObject. In addition, the private slots
|
Executes tests declared in \a testObject. In addition, the private slots
|
||||||
\c{initTestCase()}, \c{cleanupTestCase()}, \c{init()} and \c{cleanup()}
|
\c{initTestCase()}, \c{cleanupTestCase()}, \c{init()} and \c{cleanup()}
|
||||||
@ -2163,6 +2175,7 @@ int QTest::qExec(QObject *testObject, int argc, char **argv)
|
|||||||
_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG);
|
_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG);
|
||||||
# endif
|
# endif
|
||||||
SetErrorMode(SetErrorMode(0) | SEM_NOGPFAULTERRORBOX);
|
SetErrorMode(SetErrorMode(0) | SEM_NOGPFAULTERRORBOX);
|
||||||
|
SetUnhandledExceptionFilter(windowsFaultHandler);
|
||||||
} // !noCrashHandler
|
} // !noCrashHandler
|
||||||
#endif // Q_OS_WIN) && !Q_OS_WINCE
|
#endif // Q_OS_WIN) && !Q_OS_WINCE
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user