From 992d4b4b8d3f3a630a2cf00d593ee4ce4dfa7ce8 Mon Sep 17 00:00:00 2001 From: Christoph Berg Date: Thu, 9 Jan 2025 22:12:06 +0100 Subject: New upstream version 2.7.0~rc8+repack --- ExceptionCatchingApplication.hpp | 98 ++++++++++++++++++++-------------------- 1 file changed, 49 insertions(+), 49 deletions(-) (limited to 'ExceptionCatchingApplication.hpp') diff --git a/ExceptionCatchingApplication.hpp b/ExceptionCatchingApplication.hpp index 175edb8e..b9a3f961 100755 --- a/ExceptionCatchingApplication.hpp +++ b/ExceptionCatchingApplication.hpp @@ -1,49 +1,49 @@ -#ifndef EXCEPTION_CATCHING_APPLICATION_HPP__ -#define EXCEPTION_CATCHING_APPLICATION_HPP__ - -#include - -#include -#include "Logger.hpp" - -class QObject; -class QEvent; - -// -// We can't use the GUI after QApplication::exit() is called so -// uncaught exceptions can get lost on Windows systems where there is -// no console terminal, so here we override QApplication::notify() and -// wrap the base class call with a try block to catch and log any -// uncaught exceptions. -// -class ExceptionCatchingApplication - : public QApplication -{ -public: - explicit ExceptionCatchingApplication (int& argc, char * * argv) - : QApplication {argc, argv} - { - } - bool notify (QObject * receiver, QEvent * e) override - { - try - { - return QApplication::notify (receiver, e); - } - catch (std::exception const& e) - { - LOG_FATAL ("Unexpected exception caught in event loop: " << e.what ()); - } - catch (...) - { - LOG_FATAL ("Unexpected unknown exception caught in event loop"); - } - // There's nowhere to go from here as Qt will not pass exceptions - // through the event loop, so we must abort. - boost::log::core::get ()->flush (); - qFatal ("Aborting"); - return false; - } -}; - -#endif +#ifndef EXCEPTION_CATCHING_APPLICATION_HPP__ +#define EXCEPTION_CATCHING_APPLICATION_HPP__ + +#include + +#include +#include "Logger.hpp" + +class QObject; +class QEvent; + +// +// We can't use the GUI after QApplication::exit() is called so +// uncaught exceptions can get lost on Windows systems where there is +// no console terminal, so here we override QApplication::notify() and +// wrap the base class call with a try block to catch and log any +// uncaught exceptions. +// +class ExceptionCatchingApplication + : public QApplication +{ +public: + explicit ExceptionCatchingApplication (int& argc, char * * argv) + : QApplication {argc, argv} + { + } + bool notify (QObject * receiver, QEvent * e) override + { + try + { + return QApplication::notify (receiver, e); + } + catch (std::exception const& e) + { + LOG_FATAL ("Unexpected exception caught in event loop: " << e.what ()); + } + catch (...) + { + LOG_FATAL ("Unexpected unknown exception caught in event loop"); + } + // There's nowhere to go from here as Qt will not pass exceptions + // through the event loop, so we must abort. + boost::log::core::get ()->flush (); + qFatal ("Aborting"); + return false; + } +}; + +#endif -- cgit v1.2.3