From 529ac8041a3f96dbb4327e5ae0cab40372b7276e Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Fri, 7 Sep 2018 15:45:35 -0700 Subject: [PATCH] Only write a dump for the first unhandled exception --- app/main.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/main.cpp b/app/main.cpp index 252c1185..98746fd9 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -134,8 +134,15 @@ void qtLogToDiskHandler(QtMsgType type, const QMessageLogContext&, const QString #include #include +static UINT s_HitUnhandledException = 0; + LONG WINAPI UnhandledExceptionHandler(struct _EXCEPTION_POINTERS *ExceptionInfo) { + // Only write a dump for the first unhandled exception + if (InterlockedCompareExchange(&s_HitUnhandledException, 1, 0) != 0) { + return EXCEPTION_CONTINUE_SEARCH; + } + WCHAR dmpFileName[MAX_PATH]; swprintf_s(dmpFileName, L"%ls\\Moonlight-%I64u.dmp", (PWCHAR)QDir::toNativeSeparators(Path::getLogDir()).utf16(), QDateTime::currentSecsSinceEpoch());