mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-02 23:35:40 +08:00
Prevent Qt handling Windows Messages while the fatal error message is open
This commit is contained in:
@@ -18,6 +18,7 @@
|
|||||||
#include "crashpad/client/simulate_crash.h"
|
#include "crashpad/client/simulate_crash.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <QAbstractNativeEventFilter>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QGlobalStatic>
|
#include <QGlobalStatic>
|
||||||
#include <QMessageLogContext>
|
#include <QMessageLogContext>
|
||||||
@@ -57,7 +58,20 @@ namespace BlackMisc
|
|||||||
#if defined(Q_CC_MSVC) && defined(QT_NO_DEBUG)
|
#if defined(Q_CC_MSVC) && defined(QT_NO_DEBUG)
|
||||||
if (type == QtFatalMsg)
|
if (type == QtFatalMsg)
|
||||||
{
|
{
|
||||||
|
struct EventFilter : public QAbstractNativeEventFilter
|
||||||
|
{
|
||||||
|
// Prevent Qt from handling Windows Messages while the messagebox is open
|
||||||
|
virtual bool nativeEventFilter(const QByteArray &, void *message, long *result) override
|
||||||
|
{
|
||||||
|
auto msg = static_cast<MSG *>(message);
|
||||||
|
*result = DefWindowProc(msg->hwnd, msg->message, msg->wParam, msg->lParam);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
EventFilter ef;
|
||||||
|
qApp->installNativeEventFilter(&ef);
|
||||||
MessageBoxW(nullptr, message.toStdWString().c_str(), nullptr, MB_OK); // display assert dialog in release build
|
MessageBoxW(nullptr, message.toStdWString().c_str(), nullptr, MB_OK); // display assert dialog in release build
|
||||||
|
qApp->removeNativeEventFilter(&ef);
|
||||||
# if defined(BLACK_USE_CRASHPAD)
|
# if defined(BLACK_USE_CRASHPAD)
|
||||||
CRASHPAD_SIMULATE_CRASH(); // workaround inability to catch __fastfail
|
CRASHPAD_SIMULATE_CRASH(); // workaround inability to catch __fastfail
|
||||||
# endif
|
# endif
|
||||||
|
|||||||
Reference in New Issue
Block a user