diff options
| author | tony mancill <tmancill@debian.org> | 2026-04-12 08:46:47 -0700 |
|---|---|---|
| committer | tony mancill <tmancill@debian.org> | 2026-04-12 08:46:47 -0700 |
| commit | cd2dad3bc7ae0ee0a18b7b20a945009362ec3851 (patch) | |
| tree | 5a622ec4193e9bc899f6499f936848a661be29cb /ExceptionCatchingApplication.hpp | |
| parent | 558c0b9d6ecf70c5222e2069ece1fea3656c75d7 (diff) | |
| parent | 291b3817bf0c7a742e9e17d42c94fc8c9530e40d (diff) | |
Merge branch 'debian/latest' into debian/trixie-backports
Diffstat (limited to 'ExceptionCatchingApplication.hpp')
| -rw-r--r--[-rwxr-xr-x] | ExceptionCatchingApplication.hpp | 98 |
1 files changed, 49 insertions, 49 deletions
diff --git a/ExceptionCatchingApplication.hpp b/ExceptionCatchingApplication.hpp index 175edb8e..b9a3f961 100755..100644 --- a/ExceptionCatchingApplication.hpp +++ b/ExceptionCatchingApplication.hpp @@ -1,49 +1,49 @@ -#ifndef EXCEPTION_CATCHING_APPLICATION_HPP__
-#define EXCEPTION_CATCHING_APPLICATION_HPP__
-
-#include <QApplication>
-
-#include <boost/log/core.hpp>
-#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 <QApplication> + +#include <boost/log/core.hpp> +#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 |
