mirror of
https://git.outfoxxed.me/quickshell/quickshell.git
synced 2026-04-10 06:11:54 +10:00
crash: add std::terminate handler
This commit is contained in:
parent
313f4e47f6
commit
9bf752ac33
1 changed files with 19 additions and 0 deletions
|
|
@ -5,9 +5,11 @@
|
|||
#include <csignal>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <exception>
|
||||
|
||||
#include <cpptrace/basic.hpp>
|
||||
#include <cpptrace/forward.hpp>
|
||||
#include <cpptrace/utils.hpp>
|
||||
#include <qdatastream.h>
|
||||
#include <qfile.h>
|
||||
#include <qlogging.h>
|
||||
|
|
@ -156,6 +158,21 @@ void signalHandler(
|
|||
}
|
||||
}
|
||||
|
||||
void handleCppTerminate() {
|
||||
if (auto ptr = std::current_exception()) {
|
||||
try {
|
||||
std::rethrow_exception(ptr);
|
||||
} catch (std::exception& e) {
|
||||
qFatal().nospace() << "Terminate called with C++ exception ("
|
||||
<< cpptrace::demangle(typeid(e).name()).data() << "): " << e.what();
|
||||
} catch (...) {
|
||||
qFatal() << "Terminate called with non exception object";
|
||||
}
|
||||
}
|
||||
|
||||
qFatal() << "Terminate called without active C++ exception";
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void CrashHandler::init() {
|
||||
|
|
@ -204,6 +221,8 @@ void CrashHandler::init() {
|
|||
|
||||
// NOLINTEND (misc-include-cleaner)
|
||||
|
||||
std::set_terminate(&handleCppTerminate);
|
||||
|
||||
qCInfo(logCrashHandler) << "Crash handler initialized.";
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue