|
wiRedPanda
Logic Circuit Simulator
|
Custom QApplication that wraps event dispatch with exception handling. More...
#include <Application.h>
Public Member Functions | |
| Application (int &argc, char **argv) | |
| Constructs the application with command-line arguments. | |
| bool | notify (QObject *receiver, QEvent *event) override |
| ~Application () override=default | |
| Destructor. | |
Static Public Member Functions | |
| template<typename Body> | |
| static void | guardedSlot (const QObject *context, Body &&body) noexcept |
| Wraps a slot body in try/catch and reports any exception synchronously, inside the slot's own stack frame. | |
| static void | handleException (const ExceptionInfo &info, const QObject *context) |
| Centralised exception-reporting handler used by both Application::notify (defence-in-depth on Linux/Windows) and Application::guardedSlot (the macOS-correct catch-in-slot path). | |
| static Application * | instance () |
| Returns the application instance cast to Application*. | |
| static bool | isSentryDenyMessage (const QString &message) |
Static Public Attributes | |
| static bool | interactiveMode = true |
| static bool | migrationEnabled = true |
| static bool | renderingEnabled = true |
Custom QApplication that wraps event dispatch with exception handling.
Overrides notify() to catch Pandaception and std::exception objects thrown during event processing and display appropriate error dialogs.
Definition at line 44 of file Application.h.
| Application::Application | ( | int & | argc, |
| char ** | argv ) |
Constructs the application with command-line arguments.
| argc | Argument count (passed by reference as required by QApplication). |
| argv | Argument vector. |
Definition at line 79 of file Application.cpp.
Referenced by instance().
|
overridedefault |
Destructor.
|
inlinestaticnoexcept |
Wraps a slot body in try/catch and reports any exception synchronously, inside the slot's own stack frame.
Per Qt 6.11 Exception Safety and QTBUG-15197, throwing across Qt's signal-slot dispatch is undefined behaviour; on macOS the unwinder reliably triggers std::terminate mid-stack and no upstream catch runs. guardedSlot keeps the catch frame inside the slot itself (below any Qt-internal frame) so the unwinder never crosses a structure that aborts. Reporting was originally deferred to the next event-loop iteration via a queued invokeMethod, but that hangs on macOS — the modal QMessageBox::exec() deep inside the queued dispatch never returns (see the catch block below and .claude/SENTRY_TRIAGE.md §A25). handleException is called directly instead, using a non-modal show() so it returns immediately even when interactive.
| Body | Invocable callable with no arguments returning anything. |
| context | Non-owning pointer used as the receiver hint passed to handleException. |
| body | The slot body to invoke; any thrown std::exception is caught and reported before this function returns. |
Definition at line 129 of file Application.h.
References handleException().
Referenced by ICController::addICFromFile(), ExportController::exportArduinoDialog(), ExportController::exportImageDialog(), ExportController::exportPdfDialog(), ExportController::exportSystemVerilogDialog(), WorkspaceManager::newTab(), WorkspaceManager::openFile(), WorkspaceManager::reloadFile(), WorkspaceManager::saveFile(), WorkspaceManager::saveFileAs(), and ICController::showRemoveICHint().
|
static |
Centralised exception-reporting handler used by both Application::notify (defence-in-depth on Linux/Windows) and Application::guardedSlot (the macOS-correct catch-in-slot path).
Shows a QMessageBox::critical when interactiveMode is true, and forwards the event to Sentry as a handled:1 warning when sentry is compiled in. Safe to call from a deferred QMetaObject::invokeMethod callback (the exception has finished unwinding by then).
Definition at line 127 of file Application.cpp.
References ExceptionInfo::englishMessage, ExceptionInfo::file, interactiveMode, ExceptionInfo::line, and ExceptionInfo::what.
Referenced by guardedSlot(), and notify().
|
static |
Returns the application instance cast to Application*.
Definition at line 91 of file Application.cpp.
References Application().
Referenced by LanguageManager::loadTranslation(), ThemeAttributes::setTheme(), ThemeManager::setTheme(), and LanguageManager::~LanguageManager().
|
static |
Returns true if message matches any deny pattern that should be dropped before being sent to Sentry. Always compiled (independent of HAVE_SENTRY) so the deny-list policy is unit-testable.
Definition at line 69 of file Application.cpp.
|
override |
Definition at line 96 of file Application.cpp.
References handleException().
|
inlinestatic |
When false, suppresses informational dialogs (e.g. version-mismatch warnings). Stays false in BOTH MCP modes: an automated session can't dismiss a QMessageBox. Visual concerns are governed by renderingEnabled instead.
Definition at line 73 of file Application.h.
Referenced by UpdateController::checkForUpdates(), handleException(), WorkSpace::load(), WorkspaceManager::loadAutosaveFiles(), main(), WorkSpace::save(), MainWindow::show(), and Simulation::update().
|
inlinestatic |
When true, old-format files are automatically backed up and re-saved in the current format on load. Independent of interactiveMode so tests can enable migration without triggering any QMessageBox dialogs.
Definition at line 85 of file Application.h.
Referenced by WorkSpace::load().
|
inlinestatic |
When false, skips wire-geometry construction (Connection::updatePath) as a throughput optimization for contexts that never paint or export: unit tests and fuzz harnesses. Must stay true whenever anything can be rendered — including headless –mcp, whose export_image paints the scene off-screen.
Definition at line 80 of file Application.h.
Referenced by Connection::updatePath().