reorganize crash handling
authorDaniel Albers <daniel@lbers.com>
Tue, 6 Oct 2009 22:15:06 +0000 (00:15 +0200)
committerDaniel Albers <daniel@lbers.com>
Tue, 6 Oct 2009 22:17:06 +0000 (00:17 +0200)
When building with KDE support, internal crash handler is disabled in favor of DrKonqi

src/common/main.cpp
src/common/quassel.cpp
src/common/quassel.h
src/core/coreapplication.cpp
src/qtui/monoapplication.cpp
src/qtui/qtuiapplication.cpp

index 97a0570..d0e0840 100644 (file)
@@ -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);
 
index a979805..deaf20e 100644 (file)
@@ -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()));
 
index 4b9c5a9..fa7d02c 100644 (file)
@@ -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; }
index f0c84f3..f7f36c5 100644 (file)
@@ -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();
 }
index e63c4d2..216601a 100644 (file)
@@ -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);
 }
 
index 2aa1789..de989bb 100644 (file)
@@ -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);