diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 62b2486555..5efce2ea00 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -150,8 +150,8 @@ #include "audio/AudioScope.h" #include "avatar/AvatarManager.h" #include "avatar/MyHead.h" +#include "CrashRecoveryHandler.h" #include "CrashHandler.h" -#include "Crashpad.h" #include "devices/DdeFaceTracker.h" #include "DiscoverabilityManager.h" #include "GLCanvas.h" @@ -792,7 +792,7 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) { bool previousSessionCrashed { false }; if (!inTestMode) { - previousSessionCrashed = CrashHandler::checkForResetSettings(runningMarkerExisted, suppressPrompt); + previousSessionCrashed = CrashRecoveryHandler::checkForResetSettings(runningMarkerExisted, suppressPrompt); } // get dir to use for cache diff --git a/interface/src/Breakpad.h b/interface/src/Breakpad.h deleted file mode 100644 index 3d4c46025b..0000000000 --- a/interface/src/Breakpad.h +++ /dev/null @@ -1,20 +0,0 @@ -// -// Breakpad.h -// interface/src -// -// Created by Gabriel Calero & Cristian Duarte on 06/06/18 -// Copyright 2018 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -#ifndef hifi_Breakpad_h -#define hifi_Breakpad_h - -#include - -bool startCrashHandler(); -void setCrashAnnotation(std::string name, std::string value); - -#endif // hifi_Crashpad_h diff --git a/interface/src/CrashHandler.h b/interface/src/CrashHandler.h index bff8bba6dd..d96ecf0312 100644 --- a/interface/src/CrashHandler.h +++ b/interface/src/CrashHandler.h @@ -2,8 +2,8 @@ // CrashHandler.h // interface/src // -// Created by David Rowe on 24 Aug 2015. -// Copyright 2015 High Fidelity, Inc. +// Created by Clement Brisset on 01/19/18. +// Copyright 2018 High Fidelity, Inc. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html @@ -12,22 +12,21 @@ #ifndef hifi_CrashHandler_h #define hifi_CrashHandler_h -#include +#include -class CrashHandler { +#if HAS_CRASHPAD -public: - static bool checkForResetSettings(bool wasLikelyCrash, bool suppressPrompt = false); +bool startCrashHandler(); +void setCrashAnnotation(std::string name, std::string value); -private: - enum Action { - DELETE_INTERFACE_INI, - RETAIN_IMPORTANT_INFO, - DO_NOTHING - }; +#elif HAS_BREAKPAD - static Action promptUserForAction(bool showCrashMessage); - static void handleCrash(Action action); -}; +bool startCrashHandler(); +void setCrashAnnotation(std::string name, std::string value); -#endif // hifi_CrashHandler_h +#else + +bool startCrashHandler(); +void setCrashAnnotation(std::string name, std::string value); + +#endif // hifi_Crashpad_h diff --git a/interface/src/Breakpad.cpp b/interface/src/CrashHandler_Breakpad.cpp similarity index 86% rename from interface/src/Breakpad.cpp rename to interface/src/CrashHandler_Breakpad.cpp index cb4785305a..14b5c7c5f2 100644 --- a/interface/src/Breakpad.cpp +++ b/interface/src/CrashHandler_Breakpad.cpp @@ -1,28 +1,31 @@ // -// Breakpad.cpp +// Crashpad.cpp // interface/src // -// Created by Gabriel Calero & Cristian Duarte on 06/06/18 +// Created by Clement Brisset on 01/19/18. // Copyright 2018 High Fidelity, Inc. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include "Crashpad.h" +#include "CrashHandler.h" -#if defined(HAS_BREAKPAD) -#include +#if HAS_BREAKPAD + +#include #include #include + +#include +#include #include #include -#include -#include -#include -google_breakpad::ExceptionHandler *gBreakpadHandler; +#include + +google_breakpad::ExceptionHandler* gBreakpadHandler; std::mutex annotationMutex; QMap annotations; @@ -52,11 +55,7 @@ void setCrashAnnotation(std::string name, std::string value) { std::lock_guard guard(annotationMutex); QString qName = QString::fromStdString(name); QString qValue = QString::fromStdString(value); - if(!annotations.contains(qName)) { - annotations.insert(qName, qValue); - } else { - annotations[qName] = qValue; - } + annotations[qName] = qValue; QSettings settings(obbDir() + "/annotations.json", JSON_FORMAT); settings.clear(); diff --git a/interface/src/Crashpad.cpp b/interface/src/CrashHandler_Crashpad.cpp similarity index 94% rename from interface/src/Crashpad.cpp rename to interface/src/CrashHandler_Crashpad.cpp index 6f29d9dd23..96c7d5d538 100644 --- a/interface/src/Crashpad.cpp +++ b/interface/src/CrashHandler_Crashpad.cpp @@ -9,7 +9,7 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include "Crashpad.h" +#include "CrashHandler.h" #include @@ -114,14 +114,4 @@ void setCrashAnnotation(std::string name, std::string value) { crashpadAnnotations->SetKeyValue(name, value); } -#elif !defined(HAS_BREAKPAD) - -bool startCrashHandler() { - qDebug() << "No crash handler available."; - return false; -} - -void setCrashAnnotation(std::string name, std::string value) { -} - #endif diff --git a/interface/src/CrashHandler_None.cpp b/interface/src/CrashHandler_None.cpp new file mode 100644 index 0000000000..0d92dc2005 --- /dev/null +++ b/interface/src/CrashHandler_None.cpp @@ -0,0 +1,27 @@ +// +// Crashpad.cpp +// interface/src +// +// Created by Clement Brisset on 01/19/18. +// Copyright 2018 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#include "CrashHandler.h" + +#include +#include + +#if !defined(HAS_CRASHPAD) && !defined(HAS_BREAKPAD) + +bool startCrashHandler() { + qDebug() << "No crash handler available."; + return false; +} + +void setCrashAnnotation(std::string name, std::string value) { +} + +#endif diff --git a/interface/src/CrashHandler.cpp b/interface/src/CrashRecoveryHandler.cpp similarity index 85% rename from interface/src/CrashHandler.cpp rename to interface/src/CrashRecoveryHandler.cpp index d3079b9bf4..4bf4d04180 100644 --- a/interface/src/CrashHandler.cpp +++ b/interface/src/CrashRecoveryHandler.cpp @@ -1,5 +1,5 @@ // -// CrashHandler.cpp +// CrashRecoveryHandler.cpp // interface/src // // Created by David Rowe on 24 Aug 2015. @@ -9,7 +9,7 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include "CrashHandler.h" +#include "CrashRecoveryHandler.h" #include #include @@ -30,7 +30,7 @@ #include -bool CrashHandler::checkForResetSettings(bool wasLikelyCrash, bool suppressPrompt) { +bool CrashRecoveryHandler::checkForResetSettings(bool wasLikelyCrash, bool suppressPrompt) { QSettings::setDefaultFormat(JSON_FORMAT); QSettings settings; settings.beginGroup("Developer"); @@ -59,7 +59,7 @@ bool CrashHandler::checkForResetSettings(bool wasLikelyCrash, bool suppressPromp return wasLikelyCrash; } -CrashHandler::Action CrashHandler::promptUserForAction(bool showCrashMessage) { +CrashRecoveryHandler::Action CrashRecoveryHandler::promptUserForAction(bool showCrashMessage) { QDialog crashDialog; QLabel* label; if (showCrashMessage) { @@ -94,20 +94,20 @@ CrashHandler::Action CrashHandler::promptUserForAction(bool showCrashMessage) { if (result == QDialog::Accepted) { if (option1->isChecked()) { - return CrashHandler::DELETE_INTERFACE_INI; + return CrashRecoveryHandler::DELETE_INTERFACE_INI; } if (option2->isChecked()) { - return CrashHandler::RETAIN_IMPORTANT_INFO; + return CrashRecoveryHandler::RETAIN_IMPORTANT_INFO; } } // Dialog cancelled or "do nothing" option chosen - return CrashHandler::DO_NOTHING; + return CrashRecoveryHandler::DO_NOTHING; } -void CrashHandler::handleCrash(CrashHandler::Action action) { - if (action != CrashHandler::DELETE_INTERFACE_INI && action != CrashHandler::RETAIN_IMPORTANT_INFO) { - // CrashHandler::DO_NOTHING or unexpected value +void CrashRecoveryHandler::handleCrash(CrashRecoveryHandler::Action action) { + if (action != CrashRecoveryHandler::DELETE_INTERFACE_INI && action != CrashRecoveryHandler::RETAIN_IMPORTANT_INFO) { + // CrashRecoveryHandler::DO_NOTHING or unexpected value return; } @@ -126,7 +126,7 @@ void CrashHandler::handleCrash(CrashHandler::Action action) { QUrl address; bool tutorialComplete = false; - if (action == CrashHandler::RETAIN_IMPORTANT_INFO) { + if (action == CrashRecoveryHandler::RETAIN_IMPORTANT_INFO) { // Read avatar info // Location and orientation @@ -151,7 +151,7 @@ void CrashHandler::handleCrash(CrashHandler::Action action) { settingsFile.remove(); } - if (action == CrashHandler::RETAIN_IMPORTANT_INFO) { + if (action == CrashRecoveryHandler::RETAIN_IMPORTANT_INFO) { // Write avatar info // Location and orientation diff --git a/interface/src/CrashRecoveryHandler.h b/interface/src/CrashRecoveryHandler.h new file mode 100644 index 0000000000..64aa8ea0e4 --- /dev/null +++ b/interface/src/CrashRecoveryHandler.h @@ -0,0 +1,33 @@ +// +// CrashRecoveryHandler.h +// interface/src +// +// Created by David Rowe on 24 Aug 2015. +// Copyright 2015 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#ifndef hifi_CrashHandler_h +#define hifi_CrashHandler_h + +#include + +class CrashRecoveryHandler { + +public: + static bool checkForResetSettings(bool wasLikelyCrash, bool suppressPrompt = false); + +private: + enum Action { + DELETE_INTERFACE_INI, + RETAIN_IMPORTANT_INFO, + DO_NOTHING + }; + + static Action promptUserForAction(bool showCrashMessage); + static void handleCrash(Action action); +}; + +#endif // hifi_CrashHandler_h diff --git a/interface/src/Crashpad.h b/interface/src/Crashpad.h deleted file mode 100644 index a815ed701a..0000000000 --- a/interface/src/Crashpad.h +++ /dev/null @@ -1,20 +0,0 @@ -// -// Crashpad.h -// interface/src -// -// Created by Clement Brisset on 01/19/18. -// Copyright 2018 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -#ifndef hifi_Crashpad_h -#define hifi_Crashpad_h - -#include - -bool startCrashHandler(); -void setCrashAnnotation(std::string name, std::string value); - -#endif // hifi_Crashpad_h diff --git a/interface/src/DiscoverabilityManager.cpp b/interface/src/DiscoverabilityManager.cpp index 684539145e..d39aaa4f1a 100644 --- a/interface/src/DiscoverabilityManager.cpp +++ b/interface/src/DiscoverabilityManager.cpp @@ -23,7 +23,7 @@ #include #include -#include "Crashpad.h" +#include "CrashHandler.h" #include "Menu.h" const Discoverability::Mode DEFAULT_DISCOVERABILITY_MODE = Discoverability::Connections;