mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-11-21 11:31:51 -05:00
Flush all logging sinks before aborting due to uncaught exceptions
This commit is contained in:
parent
87bca164f8
commit
c74e115d2d
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
|
||||||
|
#include <boost/log/core.hpp>
|
||||||
#include "Logger.hpp"
|
#include "Logger.hpp"
|
||||||
|
|
||||||
class QObject;
|
class QObject;
|
||||||
@ -12,8 +13,8 @@ class QEvent;
|
|||||||
// We can't use the GUI after QApplication::exit() is called so
|
// We can't use the GUI after QApplication::exit() is called so
|
||||||
// uncaught exceptions can get lost on Windows systems where there is
|
// uncaught exceptions can get lost on Windows systems where there is
|
||||||
// no console terminal, so here we override QApplication::notify() and
|
// no console terminal, so here we override QApplication::notify() and
|
||||||
// wrap the base class call with a try block to catch and display
|
// wrap the base class call with a try block to catch and log any
|
||||||
// exceptions in a message box.
|
// uncaught exceptions.
|
||||||
//
|
//
|
||||||
class ExceptionCatchingApplication
|
class ExceptionCatchingApplication
|
||||||
: public QApplication
|
: public QApplication
|
||||||
@ -32,13 +33,15 @@ public:
|
|||||||
catch (std::exception const& e)
|
catch (std::exception const& e)
|
||||||
{
|
{
|
||||||
LOG_FATAL ("Unexpected exception caught in event loop: " << e.what ());
|
LOG_FATAL ("Unexpected exception caught in event loop: " << e.what ());
|
||||||
qFatal ("Aborting");
|
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
LOG_FATAL ("Unexpected unknown exception caught in event loop");
|
LOG_FATAL ("Unexpected unknown exception caught in event loop");
|
||||||
qFatal ("Aborting");
|
|
||||||
}
|
}
|
||||||
|
// 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;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user