From 64a8755af396f1c2791018510e22b58114e68594 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Sat, 27 Mar 2021 18:52:22 +0200 Subject: [PATCH] qt: Add BitcoinApplication::handleNonFatalException function This helper function will be used in the following commits. Co-authored-by: Russell Yanofsky --- src/qt/bitcoin.cpp | 10 ++++++++++ src/qt/bitcoin.h | 6 ++++++ 2 files changed, 16 insertions(+) diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp index aec63ffaf0b..de71b7dea7d 100644 --- a/src/qt/bitcoin.cpp +++ b/src/qt/bitcoin.cpp @@ -426,6 +426,16 @@ void BitcoinApplication::handleRunawayException(const QString &message) ::exit(EXIT_FAILURE); } +void BitcoinApplication::handleNonFatalException(const QString& message) +{ + assert(QThread::currentThread() == thread()); + QMessageBox::warning( + nullptr, tr("Internal error"), + tr("An internal error occurred. %1 will attempt to continue safely. This is " + "an unexpected bug which can be reported as described below.").arg(PACKAGE_NAME) % + QLatin1String("

") % GUIUtil::MakeHtmlLink(message, PACKAGE_BUGREPORT)); +} + WId BitcoinApplication::getMainWinId() const { if (!window) diff --git a/src/qt/bitcoin.h b/src/qt/bitcoin.h index 69e0a5921e7..5fd6bd607f2 100644 --- a/src/qt/bitcoin.h +++ b/src/qt/bitcoin.h @@ -99,6 +99,12 @@ public Q_SLOTS: /// Handle runaway exceptions. Shows a message box with the problem and quits the program. void handleRunawayException(const QString &message); + /** + * A helper function that shows a message box + * with details about a non-fatal exception. + */ + void handleNonFatalException(const QString& message); + Q_SIGNALS: void requestedInitialize(); void requestedShutdown();