From 478eeea73e6ea6a8eddbd5cc23bb0241df80274a Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 16 Nov 2018 19:27:02 +0400 Subject: [PATCH] Add custom Qt message handler for crashes. --- Telegram/SourceFiles/core/crash_reports.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Telegram/SourceFiles/core/crash_reports.cpp b/Telegram/SourceFiles/core/crash_reports.cpp index ecad967534..96b754a437 100644 --- a/Telegram/SourceFiles/core/crash_reports.cpp +++ b/Telegram/SourceFiles/core/crash_reports.cpp @@ -115,6 +115,21 @@ void InstallOperatorNewHandler() { }); } +void InstallQtMessageHandler() { + static QtMessageHandler original = nullptr; + original = qInstallMessageHandler([]( + QtMsgType type, + const QMessageLogContext &context, + const QString &message) { + if (original) { + original(type, context, message); + } + if (type == QtFatalMsg) { + Unexpected("Qt FATAL message was generated!"); + } + }); +} + Qt::HANDLE ReportingThreadId = nullptr; bool ReportingHeaderWritten = false; QMutex ReportingMutex; @@ -450,6 +465,7 @@ Status Restart() { } InstallOperatorNewHandler(); + InstallQtMessageHandler(); return Started; }