From 906391224228274450914361efd104630827e580 Mon Sep 17 00:00:00 2001 From: Daniel Albers Date: Wed, 7 Oct 2009 00:15:06 +0200 Subject: [PATCH] reorganize crash handling When building with KDE support, internal crash handler is disabled in favor of DrKonqi --- src/common/main.cpp | 2 +- src/common/quassel.cpp | 42 ++++++++++++++++++------------------ src/common/quassel.h | 3 +++ src/core/coreapplication.cpp | 4 ++++ src/qtui/monoapplication.cpp | 3 +++ src/qtui/qtuiapplication.cpp | 3 +++ 6 files changed, 35 insertions(+), 22 deletions(-) diff --git a/src/common/main.cpp b/src/common/main.cpp index 97a05704..d0e0840a 100644 --- a/src/common/main.cpp +++ b/src/common/main.cpp @@ -69,7 +69,7 @@ int main(int argc, char **argv) { ki18n("A modern, distributed IRC client")); aboutData.addLicense(KAboutData::License_GPL_V2); aboutData.addLicense(KAboutData::License_GPL_V3); - aboutData.setBugAddress("http://bugs.quassel-irc.org"); + aboutData.setBugAddress("http://bugs.quassel-irc.org/projects/quassel-irc/issues/new"); aboutData.setOrganizationDomain(Quassel::buildInfo().organizationDomain.toUtf8()); KCmdLineArgs::init(argc, argv, &aboutData); diff --git a/src/common/quassel.cpp b/src/common/quassel.cpp index a9798054..deaf20e0 100644 --- a/src/common/quassel.cpp +++ b/src/common/quassel.cpp @@ -50,6 +50,7 @@ bool Quassel::_initialized = false; bool Quassel::DEBUG = false; QString Quassel::_coreDumpFileName; Quassel *Quassel::_instance = 0; +bool Quassel::_handleCrashes = true; Quassel::Quassel() { Q_ASSERT(!_instance); @@ -58,27 +59,6 @@ Quassel::Quassel() { // We catch SIGTERM and SIGINT (caused by Ctrl+C) to graceful shutdown Quassel. signal(SIGTERM, handleSignal); signal(SIGINT, handleSignal); - - // we have crashhandler for win32 and unix (based on execinfo). - // on mac os we use it's integrated backtrace generator -#if defined(Q_OS_WIN32) || (defined(HAVE_EXECINFO) && !defined(Q_OS_MAC)) - -# ifndef Q_OS_WIN32 - // we only handle crashes ourselves if coredumps are disabled - struct rlimit *limit = (rlimit *) malloc(sizeof(struct rlimit)); - int rc = getrlimit(RLIMIT_CORE, limit); - - if(rc == -1 || !((long)limit->rlim_cur > 0 || limit->rlim_cur == RLIM_INFINITY)) { -# endif - signal(SIGABRT, handleSignal); - signal(SIGSEGV, handleSignal); -# ifndef Q_OS_WIN32 - signal(SIGBUS, handleSignal); - } - free(limit); -# endif - -#endif } Quassel::~Quassel() { @@ -89,6 +69,26 @@ bool Quassel::init() { if(_initialized) return true; // allow multiple invocations because of MonolithicApplication + if (_handleCrashes) { + // we have crashhandler for win32 and unix (based on execinfo). +#if defined(Q_OS_WIN32) || defined(HAVE_EXECINFO) +# ifndef Q_OS_WIN32 + // we only handle crashes ourselves if coredumps are disabled + struct rlimit *limit = (rlimit *) malloc(sizeof(struct rlimit)); + int rc = getrlimit(RLIMIT_CORE, limit); + + if(rc == -1 || !((long)limit->rlim_cur > 0 || limit->rlim_cur == RLIM_INFINITY)) { +# endif /* Q_OS_WIN32 */ + signal(SIGABRT, handleSignal); + signal(SIGSEGV, handleSignal); +# ifndef Q_OS_WIN32 + signal(SIGBUS, handleSignal); + } + free(limit); +# endif /* Q_OS_WIN32 */ +#endif /* Q_OS_WIN32 || HAVE_EXECINFO */ + } + _initialized = true; qsrand(QTime(0,0,0).secsTo(QTime::currentTime())); diff --git a/src/common/quassel.h b/src/common/quassel.h index 4b9c5a91..fa7d02c9 100644 --- a/src/common/quassel.h +++ b/src/common/quassel.h @@ -111,6 +111,7 @@ protected: inline void setRunMode(RunMode mode); inline void setDataDirPaths(const QStringList &paths); QStringList findDataDirPaths() const; + inline void disableCrashhandler(); private: void registerMetaTypes(); @@ -123,6 +124,7 @@ private: static AbstractCliParser *_cliParser; static RunMode _runMode; static bool _initialized; + static bool _handleCrashes; static QString _coreDumpFileName; static QString _configDirPath; @@ -134,6 +136,7 @@ const Quassel::BuildInfo & Quassel::buildInfo() { return _buildInfo; } Quassel::RunMode Quassel::runMode() { return _runMode; } void Quassel::setRunMode(Quassel::RunMode mode) { _runMode = mode; } void Quassel::setDataDirPaths(const QStringList &paths) { _dataDirPaths = paths; } +void Quassel::disableCrashhandler() { _handleCrashes = false; } void Quassel::setCliParser(AbstractCliParser *parser) { _cliParser = parser; } AbstractCliParser *Quassel::cliParser() { return _cliParser; } diff --git a/src/core/coreapplication.cpp b/src/core/coreapplication.cpp index f0c84f32..f7f36c54 100644 --- a/src/core/coreapplication.cpp +++ b/src/core/coreapplication.cpp @@ -63,6 +63,10 @@ bool CoreApplicationInternal::init() { CoreApplication::CoreApplication(int &argc, char **argv) : QCoreApplication(argc, argv), Quassel() { +#ifdef Q_OS_MAC + disableCrashhandler(); +#endif /* Q_OS_MAC */ + setRunMode(Quassel::CoreOnly); _internal = new CoreApplicationInternal(); } diff --git a/src/qtui/monoapplication.cpp b/src/qtui/monoapplication.cpp index e63c4d22..216601aa 100644 --- a/src/qtui/monoapplication.cpp +++ b/src/qtui/monoapplication.cpp @@ -30,6 +30,9 @@ MonolithicApplication::MonolithicApplication(int &argc, char **argv) _internalInitDone(false) { _internal = new CoreApplicationInternal(); // needed for parser options +#if defined(HAVE_KDE) || defined(Q_OS_MAC) + disableCrashhandler(); +#endif /* HAVE_KDE || Q_OS_MAC */ setRunMode(Quassel::Monolithic); } diff --git a/src/qtui/qtuiapplication.cpp b/src/qtui/qtuiapplication.cpp index 2aa17891..de989bbd 100644 --- a/src/qtui/qtuiapplication.cpp +++ b/src/qtui/qtuiapplication.cpp @@ -56,6 +56,9 @@ QtUiApplication::QtUiApplication(int &argc, char **argv) #endif /* HAVE_KDE */ +#if defined(HAVE_KDE) || defined(Q_OS_MAC) + disableCrashhandler(); +#endif /* HAVE_KDE || Q_OS_MAC */ setRunMode(Quassel::ClientOnly); qInstallMsgHandler(Client::logMessage); -- 2.20.1