KCrash
Typedefs | |
typedef QFlags< CrashFlag > | CrashFlags |
typedef void(* | HandlerType) (int) |
Enumerations | |
enum | CrashFlag { KeepFDs = 1 , SaferDialog = 2 , AlwaysDirectly , AutoRestart = 8 } |
Functions | |
KCRASH_EXPORT HandlerType | crashHandler () |
KCRASH_EXPORT void | defaultCrashHandler (int signal) |
KCRASH_EXPORT HandlerType | emergencySaveFunction () |
std::optional< ExceptionMetadata > | exceptionMetadata () |
KCRASH_EXPORT void | initialize () |
KCRASH_EXPORT bool | isDrKonqiEnabled () |
void | setApplicationFilePath (const QString &filePath) |
KCRASH_EXPORT void | setCrashHandler (HandlerType handler=defaultCrashHandler) |
KCRASH_EXPORT void | setDrKonqiEnabled (bool enabled) |
KCRASH_EXPORT void | setEmergencySaveFunction (HandlerType saveFunction=nullptr) |
KCRASH_EXPORT void | setErrorExtraData (const QHash< QString, QString > &details) |
KCRASH_EXPORT void | setErrorMessage (const QString &message) |
KCRASH_EXPORT void | setErrorTags (const QHash< QString, QString > &details) |
KCRASH_EXPORT void | setFlags (KCrash::CrashFlags flags) |
void | startProcess (int argc, const char *argv[], bool waitAndExit) |
Detailed Description
This namespace contains functions to handle crashes.
It allows you to set a crash handler function that will be called when your application crashes and also provides a default crash handler that implements the following functionality:
- Launches the KDE crash display application (DrKonqi) to let the user report the bug and/or debug it.
- Calls an emergency save function that you can set with setEmergencySaveFunction() to attempt to save the application's data.
- Autorestarts your application.
- Note
- All the above features are optional and you need to enable them explicitly. By default, the defaultCrashHandler() will not do anything. However, if you are using KApplication, it will by default enable launching DrKonqi on crashes, unless the –nocrashhandler argument was passed on the command line or the environment variable KDE_DEBUG is set to any value.
Typedef Documentation
◆ CrashFlags
typedef QFlags< CrashFlag > KCrash::CrashFlags |
◆ HandlerType
typedef void(* KCrash::HandlerType) (int) |
Enumeration Type Documentation
◆ CrashFlag
enum KCrash::CrashFlag |
Options to determine how the default crash handler should behave.
- See also
- CrashFlags
Enumerator | |
---|---|
KeepFDs | don't close all file descriptors immediately |
SaferDialog | start DrKonqi without arbitrary disk access |
AlwaysDirectly | never try to to start DrKonqi via kdeinit. Use fork() and exec() instead.
|
AutoRestart | autorestart this application. Only sensible for KUniqueApplications.
|
Function Documentation
◆ crashHandler()
KCrash::HandlerType KCrash::crashHandler | ( | ) |
Returns the installed crash handler.
- Returns
- the crash handler
Definition at line 432 of file kcrash.cpp.
◆ defaultCrashHandler()
void KCrash::defaultCrashHandler | ( | int | signal | ) |
The default crash handler.
Do not call this function directly. Instead, use setCrashHandler() to set it as your application's crash handler.
- Parameters
-
signal the signal number
- Note
- If you implement your own crash handler, you will have to call this function from your implementation if you want to use the features of this namespace.
Definition at line 455 of file kcrash.cpp.
◆ emergencySaveFunction()
KCrash::HandlerType KCrash::emergencySaveFunction | ( | ) |
Returns the currently set emergency save function.
- Returns
- the emergency save function
Definition at line 283 of file kcrash.cpp.
◆ exceptionMetadata()
std::optional< ExceptionMetadata > KCrash::exceptionMetadata | ( | ) |
Definition at line 34 of file exception.cpp.
◆ initialize()
void KCrash::initialize | ( | ) |
Initialize KCrash.
This does nothing if $KDE_DEBUG is set.
Call this in your main() after setting up KAboutData to ensure that the crash handler is launched.
- Since
- 5.15
Definition at line 209 of file kcrash.cpp.
◆ isDrKonqiEnabled()
bool KCrash::isDrKonqiEnabled | ( | ) |
Returns true if DrKonqi is set to be launched from the crash handler or false otherwise.
- Since
- 4.5
Definition at line 374 of file kcrash.cpp.
◆ setApplicationFilePath()
void KCrash::setApplicationFilePath | ( | const QString & | filePath | ) |
Definition at line 328 of file kcrash.cpp.
◆ setCrashHandler()
void KCrash::setCrashHandler | ( | HandlerType | handler = defaultCrashHandler | ) |
Install a function to be called when a crash occurs.
A crash occurs when one of the following signals is caught: SIGSEGV, SIGBUS, SIGFPE, SIGILL, SIGABRT.
- Parameters
-
handler this can be one of: - null, in which case signal catching is disabled (by setting the signal handler for the crash signals to SIG_DFL)
- a user defined function in the form: static (if in a class) void myCrashHandler(int);
- if handler is omitted, the default crash handler is installed
- Note
- If you use setDrKonqiEnabled(true), setEmergencySaveFunction(myfunc) or setFlags(AutoRestart), you do not need to call this function explicitly. The default crash handler is automatically installed by those functions if needed. However, if you set a custom crash handler, those functions will not change it.
Definition at line 379 of file kcrash.cpp.
◆ setDrKonqiEnabled()
void KCrash::setDrKonqiEnabled | ( | bool | enabled | ) |
Enables or disables launching DrKonqi from the crash handler.
By default, launching DrKonqi is enabled when QCoreApplication is created. To disable it:
- Note
- It is the crash handler's responsibility to launch DrKonqi. Therefore, if no crash handler is set, this method also installs the default crash handler to ensure that DrKonqi will be launched.
- Since
- 4.5
Definition at line 351 of file kcrash.cpp.
◆ setEmergencySaveFunction()
void KCrash::setEmergencySaveFunction | ( | HandlerType | saveFunction = nullptr | ) |
Installs a function which should try to save the application's data.
- Note
- It is the crash handler's responsibility to call this function. Therefore, if no crash handler is set, the default crash handler is installed to ensure the save function will be called.
- Parameters
-
saveFunction the handler to install
Definition at line 270 of file kcrash.cpp.
◆ setErrorExtraData()
Sets the error details to be included in the crash report.
These are rendered as extra blobs of data and can any form. Note that these are subject to event ingestion limits and should be kept at reasonable sizes to prevent event rejection.
- Since
- 6.11
Definition at line 819 of file kcrash.cpp.
◆ setErrorMessage()
void KCrash::setErrorMessage | ( | const QString & | message | ) |
Allows providing information to be included in the bug report.
Prefer setErrorExtraInformation as it is more flexible.
- Since
- 5.69
Definition at line 803 of file kcrash.cpp.
◆ setErrorTags()
Sets the error tags to be included in the crash report.
These are rendered as tags in the crash reporting system. Note that server-side limits apply to the length of these so you should only put short, sortable data in here.
- Since
- 6.11
Definition at line 808 of file kcrash.cpp.
◆ setFlags()
void KCrash::setFlags | ( | KCrash::CrashFlags | flags | ) |
Set options to determine how the default crash handler should behave.
- Parameters
-
flags ORed together CrashFlags
Definition at line 313 of file kcrash.cpp.
◆ startProcess()
void KCrash::startProcess | ( | int | argc, |
const char * | argv[], | ||
bool | waitAndExit ) |
Definition at line 731 of file kcrash.cpp.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 31 2025 12:02:47 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.