Custom user code callback after exception is processed

Signed-off-by: Max Risuhin <risuhin.max@gmail.com>
This commit is contained in:
Max Risuhin 2018-08-23 21:05:41 +03:00
parent db53e5260b
commit 307f538d4b
No known key found for this signature in database
GPG Key ID: BF733F5ACA0B4448
2 changed files with 13 additions and 2 deletions

View File

@ -12,6 +12,7 @@
#endif
QString g_crashReporterPath;
ExceptionPostHandledCallback g_exceptionPostHandledCallback = nullptr;
bool handleException(QString path) {
const QStringList argumentList = {
@ -24,6 +25,10 @@ bool handleException(QString path) {
qDebug() << "Hander process path:" << g_crashReporterPath;
qDebug() << "Crash handler arguments list: " << argumentList;
QProcess::startDetached(g_crashReporterPath, argumentList);
if (g_exceptionPostHandledCallback) {
g_exceptionPostHandledCallback();
}
return true;
}
@ -51,8 +56,10 @@ bool minidumpReadyCallback(const char *dump_dir,
}
#endif
ExceptionGlobalHandler::ExceptionGlobalHandler(const QString& crashReporterPath) {
ExceptionGlobalHandler::ExceptionGlobalHandler(const QString& crashReporterPath,
ExceptionPostHandledCallback postHandledCallback) {
g_crashReporterPath = crashReporterPath;
g_exceptionPostHandledCallback = postHandledCallback;
initilize();
}
@ -74,3 +81,4 @@ ExceptionGlobalHandler::~ExceptionGlobalHandler() {
breakpadHandler = nullptr;
}
}

View File

@ -7,10 +7,13 @@ namespace google_breakpad {
class ExceptionHandler;
}
typedef void (*ExceptionPostHandledCallback)();
class ExceptionGlobalHandler
{
public:
ExceptionGlobalHandler(const QString& crashReporterPath);
ExceptionGlobalHandler(const QString& crashReporterPath,
ExceptionPostHandledCallback postHandledCallback = nullptr);
~ExceptionGlobalHandler();
private: