forked from qt-creator/qt-creator
Use RAII for crash handler setup/cleanup
Change-Id: I71205c45ee01eeaf1d2c991ec625f6a66be1e851 Reviewed-by: Christian Kandeler <christian.kandeler@theqtcompany.com>
This commit is contained in:
@@ -317,7 +317,7 @@ int main(int argc, char **argv)
|
|||||||
const int threadCount = QThreadPool::globalInstance()->maxThreadCount();
|
const int threadCount = QThreadPool::globalInstance()->maxThreadCount();
|
||||||
QThreadPool::globalInstance()->setMaxThreadCount(qMax(4, 2 * threadCount));
|
QThreadPool::globalInstance()->setMaxThreadCount(qMax(4, 2 * threadCount));
|
||||||
|
|
||||||
setupCrashHandler(); // Display a backtrace once a serious signal is delivered.
|
CrashHandlerSetup setupCrashHandler; // Display a backtrace once a serious signal is delivered.
|
||||||
|
|
||||||
#ifdef ENABLE_QT_BREAKPAD
|
#ifdef ENABLE_QT_BREAKPAD
|
||||||
QtSystemExceptionHandler systemExceptionHandler;
|
QtSystemExceptionHandler systemExceptionHandler;
|
||||||
@@ -518,7 +518,5 @@ int main(int argc, char **argv)
|
|||||||
// shutdown plugin manager on the exit
|
// shutdown plugin manager on the exit
|
||||||
QObject::connect(&app, SIGNAL(aboutToQuit()), &pluginManager, SLOT(shutdown()));
|
QObject::connect(&app, SIGNAL(aboutToQuit()), &pluginManager, SLOT(shutdown()));
|
||||||
|
|
||||||
const int r = app.exec();
|
return app.exec();
|
||||||
cleanupCrashHandler();
|
|
||||||
return r;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ extern "C" void signalHandler(int signal)
|
|||||||
}
|
}
|
||||||
#endif // BUILD_CRASH_HANDLER
|
#endif // BUILD_CRASH_HANDLER
|
||||||
|
|
||||||
void setupCrashHandler()
|
CrashHandlerSetup::CrashHandlerSetup()
|
||||||
{
|
{
|
||||||
#ifdef BUILD_CRASH_HANDLER
|
#ifdef BUILD_CRASH_HANDLER
|
||||||
if (qgetenv("QTC_USE_CRASH_HANDLER").isEmpty())
|
if (qgetenv("QTC_USE_CRASH_HANDLER").isEmpty())
|
||||||
@@ -138,7 +138,7 @@ void setupCrashHandler()
|
|||||||
#endif // BUILD_CRASH_HANDLER
|
#endif // BUILD_CRASH_HANDLER
|
||||||
}
|
}
|
||||||
|
|
||||||
void cleanupCrashHandler()
|
CrashHandlerSetup::~CrashHandlerSetup()
|
||||||
{
|
{
|
||||||
#ifdef BUILD_CRASH_HANDLER
|
#ifdef BUILD_CRASH_HANDLER
|
||||||
delete[] crashHandlerPathC;
|
delete[] crashHandlerPathC;
|
||||||
|
|||||||
@@ -31,7 +31,11 @@
|
|||||||
#ifndef CRASHHANDLERSETUP_H
|
#ifndef CRASHHANDLERSETUP_H
|
||||||
#define CRASHHANDLERSETUP_H
|
#define CRASHHANDLERSETUP_H
|
||||||
|
|
||||||
void setupCrashHandler();
|
class CrashHandlerSetup
|
||||||
void cleanupCrashHandler();
|
{
|
||||||
|
public:
|
||||||
|
CrashHandlerSetup();
|
||||||
|
~CrashHandlerSetup();
|
||||||
|
};
|
||||||
|
|
||||||
#endif // CRASHHANDLERSETUP_H
|
#endif // CRASHHANDLERSETUP_H
|
||||||
|
|||||||
Reference in New Issue
Block a user