Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
QmitkSafeApplication Class Reference

A QApplication subclass that optionally catches unhandled exceptions in the Qt event loop. More...

#include <QmitkSafeApplication.h>

Inheritance diagram for QmitkSafeApplication:
Collaboration diagram for QmitkSafeApplication:

Public Member Functions

 QmitkSafeApplication (int &argc, char **argv, bool safeMode=true)
 Construct a QmitkSafeApplication. More...
 
bool notify (QObject *receiver, QEvent *event) override
 Reimplements QApplication::notify() to catch unhandled exceptions. More...
 
void setSafeMode (bool safeMode)
 Enable or disable safe mode. More...
 
bool getSafeMode () const
 Query whether safe mode is currently enabled. More...
 

Detailed Description

A QApplication subclass that optionally catches unhandled exceptions in the Qt event loop.

When safe mode is enabled, this class reimplements QApplication::notify() to wrap all event dispatching in a try/catch block. If an unhandled exception is thrown during event processing, it is caught and an error message is displayed to the user rather than crashing the application. When safe mode is disabled, standard QApplication::notify() behavior is used.

See also
QmitkSingleApplication, mitk::BaseApplication

Definition at line 32 of file QmitkSafeApplication.h.

Constructor & Destructor Documentation

◆ QmitkSafeApplication()

QmitkSafeApplication::QmitkSafeApplication ( int &  argc,
char **  argv,
bool  safeMode = true 
)

Construct a QmitkSafeApplication.

Parameters
[in,out]argcReference to the application argument count (passed to QApplication).
[in]argvArray of command line argument strings (passed to QApplication).
[in]safeModeIf true, exception-safe event dispatching is enabled. Defaults to true.

Member Function Documentation

◆ getSafeMode()

bool QmitkSafeApplication::getSafeMode ( ) const

Query whether safe mode is currently enabled.

Returns
true if safe mode is enabled; false otherwise.

◆ notify()

bool QmitkSafeApplication::notify ( QObject *  receiver,
QEvent *  event 
)
override

Reimplements QApplication::notify() to catch unhandled exceptions.

When safe mode is enabled, exceptions thrown during event processing are caught and an error message dialog is displayed. When safe mode is disabled, this method delegates directly to QApplication::notify().

Parameters
[in]receiverThe target QObject that should receive the event.
[in]eventThe QEvent to be delivered to the receiver.
Returns
true if the event was recognized and processed by the receiver; false otherwise.

◆ setSafeMode()

void QmitkSafeApplication::setSafeMode ( bool  safeMode)

Enable or disable safe mode.

Parameters
[in]safeModeIf true, exception-catching event dispatching is enabled.

The documentation for this class was generated from the following file: