Install the crash handler earlier during startup
authorJocelyn Turcotte <jturcotte@woboq.com>
Thu, 12 Mar 2015 15:49:47 +0000 (16:49 +0100)
committerJocelyn Turcotte <jturcotte@woboq.com>
Thu, 12 Mar 2015 16:16:05 +0000 (17:16 +0100)
This moves the crash handler installation during the OCC::Application
contruction. This still leaves a window where crashes wouldn't be
caught, leaving the QtSingleApplication and theme initialization
code unreported, but isn't requiring any refactoring for now.

Issue #2952

src/gui/application.cpp
src/gui/application.h
src/gui/main.cpp

index 734f7f18b89210cdc4a7c315335478c7de1aeaf4..eb2fac6ee4bf1db5c7597afffef4f6a0cb718b92 100644 (file)
 #include <windows.h>
 #endif
 
+#if defined(WITH_CRASHREPORTER)
+#include <libcrashreporter-handler/Handler.h>
+#endif
+
 #include <QTranslator>
 #include <QMenu>
 #include <QMessageBox>
@@ -106,6 +110,11 @@ Application::Application(int &argc, char **argv) :
     if (isRunning())
         return;
 
+#if defined(WITH_CRASHREPORTER)
+    if (ConfigFile().crashReporter())
+        _crashHandler.reset(new CrashReporter::Handler( QDir::tempPath(), true, CRASHREPORTER_EXECUTABLE ));
+#endif
+
     setupLogging();
     setupTranslations();
 
index 411eb9aea426d83e628792b4b36e30cb1cc8030f..90fee1009763e50f77ea0f466afcbf09f24783fa 100644 (file)
@@ -34,6 +34,10 @@ class QMessageBox;
 class QSystemTrayIcon;
 class QSocket;
 
+namespace CrashReporter {
+class Handler;
+}
+
 namespace OCC {
 class Theme;
 class Folder;
@@ -109,6 +113,9 @@ private:
 
     QTimer _checkConnectionTimer;
 
+#if defined(WITH_CRASHREPORTER)
+    QScopedPointer<CrashReporter::Handler> _crashHandler;
+#endif
     QScopedPointer<FolderMan> _folderManager;
 
     friend class ownCloudGui; // for _startupNetworkError
index 812b659aa9f71a69dde6b77a098c2bc44cde69fd..b505fb0e52bcccede3e5d54da32350dc0e46116c 100644 (file)
 
 #include "updater/updater.h"
 
-
-#include "config.h"
-#ifdef WITH_CRASHREPORTER
-    #include "configfile.h"
-    #include <libcrashreporter-handler/Handler.h>
-#endif
-
 #include <QTimer>
 #include <QMessageBox>
 
@@ -59,12 +52,6 @@ int main(int argc, char **argv)
 #endif
     OCC::Application app(argc, argv);
 
-
-#ifdef WITH_CRASHREPORTER
-    if (ConfigFile().crashReporter())
-        new CrashReporter::Handler( QDir::tempPath(), true, CRASHREPORTER_EXECUTABLE );
-#endif
-
 #ifndef Q_OS_WIN
     signal(SIGPIPE, SIG_IGN);
 #endif