diff --git a/src/blackcore/application.cpp b/src/blackcore/application.cpp index cc99b2184..13d8dd97f 100644 --- a/src/blackcore/application.cpp +++ b/src/blackcore/application.cpp @@ -1617,7 +1617,7 @@ namespace BlackCore QDir().mkpath(database); m_crashReportDatabase = CrashReportDatabase::Initialize(qstringToFilePath(database)); auto settings = m_crashReportDatabase->GetSettings(); - settings->SetUploadsEnabled(CBuildConfig::isReleaseBuild() && m_crashDumpUploadEnabled.getThreadLocal()); + settings->SetUploadsEnabled(CBuildConfig::isReleaseBuild() && m_crashDumpSettings.getThreadLocal().isEnabled()); m_crashpadClient = std::make_unique(); m_crashpadClient->StartHandler(qstringToFilePath(handler), qstringToFilePath(database), qstringToFilePath(metrics), serverUrl.getFullUrl().toStdString(), annotations, {}, false, true); @@ -1627,15 +1627,20 @@ namespace BlackCore #endif } - void CApplication::crashDumpUploadEnabledChanged() + void CApplication::onCrashDumpUploadEnabledChanged() { #ifdef BLACK_USE_CRASHPAD if (!m_crashReportDatabase) { return; } auto settings = m_crashReportDatabase->GetSettings(); - settings->SetUploadsEnabled(CBuildConfig::isReleaseBuild() && m_crashDumpUploadEnabled.getThreadLocal()); + settings->SetUploadsEnabled(CBuildConfig::isReleaseBuild() && m_crashDumpSettings.getThreadLocal().isEnabled()); #endif } + void CApplication::setCrashInfo(const CCrashInfo &info) + { + m_crashInfo = info; + } + void CApplication::httpRequestImplInQAMThread(const QNetworkRequest &request, int logId, const CallbackSlot &callback, int maxRedirects, NetworkRequestOrPostFunction requestOrPostMethod) { // run in QAM thread diff --git a/src/blackcore/application.h b/src/blackcore/application.h index fb461c1d3..e3658051a 100644 --- a/src/blackcore/application.h +++ b/src/blackcore/application.h @@ -25,6 +25,7 @@ #include "blackmisc/slot.h" #include "blackmisc/applicationinfolist.h" #include "blackmisc/statusmessagelist.h" +#include "blackmisc/crashinfo.h" #include #include @@ -37,6 +38,7 @@ #include #include #include +#include #include #include @@ -631,20 +633,20 @@ namespace BlackCore //! Write meta information into the application directory so other swift versions can display them void tagApplicationDataDirectory(); - QNetworkConfigurationManager *m_networkConfigManager = nullptr; //!< configuration - QNetworkAccessManager *m_accessManager = nullptr; //!< single network access manager - Db::CNetworkWatchdog *m_networkWatchDog = nullptr; //!< checking DB/internet access - BlackMisc::CApplicationInfo m_applicationInfo; //!< Application if specified - QScopedPointer m_coreFacade; //!< core facade if any - QScopedPointer m_setupReader; //!< setup reader - QScopedPointer m_webDataServices; //!< web data services - QScopedPointer m_fileLogger; //!< file logger - QPointer m_cookieManager; //!< single cookie manager for our access manager - const QString m_applicationName; //!< application name - QReadWriteLock m_accessManagerLock; //!< lock to make access manager access threadsafe - CCoreFacadeConfig m_coreFacadeConfig; //!< Core facade config if any - CWebReaderFlags::WebReader m_webReadersUsed; //!< Readers to be used - Db::CDatabaseReaderConfigList m_dbReaderConfig; //!< Load or used caching? + QNetworkConfigurationManager *m_networkConfigManager = nullptr; //!< configuration + QNetworkAccessManager *m_accessManager = nullptr; //!< single network access manager + Db::CNetworkWatchdog *m_networkWatchDog = nullptr; //!< checking DB/internet access + BlackMisc::CApplicationInfo m_applicationInfo; //!< Application if specified + QScopedPointer m_coreFacade; //!< core facade if any + QScopedPointer m_setupReader; //!< setup reader + QScopedPointer m_webDataServices; //!< web data services + QScopedPointer m_fileLogger; //!< file logger + QPointer m_cookieManager; //!< single cookie manager for our access manager + const QString m_applicationName; //!< application name + QReadWriteLock m_accessManagerLock; //!< lock to make access manager access threadsafe + CCoreFacadeConfig m_coreFacadeConfig; //!< Core facade config if any + CWebReaderFlags::WebReader m_webReadersUsed; //!< Readers to be used + Db::CDatabaseReaderConfigList m_dbReaderConfig; //!< Load or used caching? bool m_noNwAccessPoint = false; //!< no network access point? bool m_useContexts = false; //!< use contexts bool m_useWebData = false; //!< use web data @@ -654,14 +656,22 @@ namespace BlackCore bool m_localSettingsLoaded = false; //!< local settings loaded? // -------------- crashpad ----------------- + //! Init the crash handler BlackMisc::CStatusMessageList initCrashHandler(); - void crashDumpUploadEnabledChanged(); + + //! Upload settings changed + void onCrashDumpUploadEnabledChanged(); + + //! Extra annotation for crash to easier identify annotation + void setCrashInfo(const BlackMisc::CCrashInfo &info); #ifdef BLACK_USE_CRASHPAD std::unique_ptr m_crashpadClient; std::unique_ptr m_crashReportDatabase; - BlackMisc::CSettingReadOnly m_crashDumpUploadEnabled { this, &CApplication::crashDumpUploadEnabledChanged }; + BlackMisc::CSettingReadOnly m_crashDumpSettings { this, &CApplication::onCrashDumpUploadEnabledChanged }; #endif + BlackMisc::CCrashInfo m_crashInfo; //!< info representing details + }; } // namespace diff --git a/src/blackcore/application/applicationsettings.h b/src/blackcore/application/applicationsettings.h index d61be2814..d1dbe429a 100644 --- a/src/blackcore/application/applicationsettings.h +++ b/src/blackcore/application/applicationsettings.h @@ -12,10 +12,12 @@ #ifndef BLACKCORE_APPLICATION_APPLICATIONSETTINGS_H #define BLACKCORE_APPLICATION_APPLICATIONSETTINGS_H -#include "blackconfig/buildconfig.h" -#include "blackmisc/settingscache.h" -#include "blackmisc/input/actionhotkeylist.h" #include "blackmisc/simulation/simulatorplugininfo.h" +#include "blackmisc/input/actionhotkeylist.h" +#include "blackmisc/settingscache.h" +#include "blackmisc/crashsettings.h" +#include "blackconfig/buildconfig.h" + #include namespace BlackCore @@ -76,16 +78,17 @@ namespace BlackCore }; //! Uploading of crash dumps is enabled or disabled - struct TCrashDumpUploadEnabled : public BlackMisc::TSettingTrait + //! \deprecated remove after changing to + struct TCrashDumpSettings : public BlackMisc::TSettingTrait { //! \copydoc BlackMisc::TSettingTrait::key - static const char *key() { return "application/crashdumpuploadenabled"; } + static const char *key() { return "application/crashdump"; } //! \copydoc BlackCore::TSettingTrait::humanReadable static const QString &humanReadable() { static const QString name("Crash dumps"); return name; } //! \copydoc BlackMisc::TSettingTrait::defaultValue - static bool defaultValue() { return true; } + // static bool defaultValue() { return BlackMisc::Settings::CCrashSettings(); } }; } // ns } // ns diff --git a/src/blackgui/components/legalinfocomponent.cpp b/src/blackgui/components/legalinfocomponent.cpp index af4995a99..d64f8d7f6 100644 --- a/src/blackgui/components/legalinfocomponent.cpp +++ b/src/blackgui/components/legalinfocomponent.cpp @@ -7,12 +7,14 @@ * contained in the LICENSE file. */ +#include "blackmisc/crashsettings.h" #include "blackmisc/statusmessage.h" #include "blackconfig/buildconfig.h" #include "legalinfocomponent.h" #include "ui_legalinfocomponent.h" using namespace BlackMisc; +using namespace BlackMisc::Settings; using namespace BlackConfig; namespace BlackGui @@ -24,8 +26,9 @@ namespace BlackGui ui(new Ui::CLegalInfoComponent) { ui->setupUi(this); - const bool cd = m_crashDumpUploadEnabled.get(); - ui->cb_CrashDumps->setChecked(cd); + + const CCrashSettings settings = m_crashDumpSettings.get(); + ui->cb_CrashDumps->setChecked(settings.isEnabled()); ui->cb_Agree->setChecked(CBuildConfig::isLocalDeveloperDebugBuild()); connect(ui->cb_CrashDumps, &QCheckBox::toggled, this, &CLegalInfoComponent::onAllowCrashDumps); } @@ -48,7 +51,9 @@ namespace BlackGui void CLegalInfoComponent::onAllowCrashDumps(bool checked) { - m_crashDumpUploadEnabled.setAndSave(checked); + CCrashSettings settings = m_crashDumpSettings.get(); + settings.setEnabled(checked); + m_crashDumpSettings.setAndSave(settings); } bool CLegalInfoWizardPage::validatePage() diff --git a/src/blackgui/components/legalinfocomponent.h b/src/blackgui/components/legalinfocomponent.h index 2f48c70e4..5179ccf51 100644 --- a/src/blackgui/components/legalinfocomponent.h +++ b/src/blackgui/components/legalinfocomponent.h @@ -48,7 +48,7 @@ namespace BlackGui void onAllowCrashDumps(bool checked); QScopedPointer ui; - BlackMisc::CSetting m_crashDumpUploadEnabled { this }; + BlackMisc::CSetting m_crashDumpSettings { this }; }; /** diff --git a/src/blackgui/components/settingsadvancedcomponent.cpp b/src/blackgui/components/settingsadvancedcomponent.cpp index 5277d7879..b7f77d0d6 100644 --- a/src/blackgui/components/settingsadvancedcomponent.cpp +++ b/src/blackgui/components/settingsadvancedcomponent.cpp @@ -7,10 +7,12 @@ * contained in the LICENSE file. */ -#include "blackgui/components/settingsadvancedcomponent.h" #include "ui_settingsadvancedcomponent.h" +#include "blackgui/components/settingsadvancedcomponent.h" +#include "blackmisc/crashsettings.h" using namespace BlackMisc; +using namespace BlackMisc::Settings; namespace BlackGui { @@ -21,7 +23,9 @@ namespace BlackGui ui(new Ui::CSettingsAdvancedComponent) { ui->setupUi(this); - ui->cb_crashDumpsUpload->setChecked(m_crashDumpUploadEnabled.getThreadLocal()); + + const CCrashSettings settings = m_crashDumpSettings.getThreadLocal(); + ui->cb_crashDumpsUpload->setChecked(settings.isEnabled()); connect(ui->cb_crashDumpsUpload, &QCheckBox::stateChanged, this, &CSettingsAdvancedComponent::crashDumpUploadEnabledChanged); } @@ -35,7 +39,10 @@ namespace BlackGui { ui->cb_crashDumpsUpload->setText(ui->cb_crashDumpsUpload->text() + " (restart needed)"); } - m_crashDumpUploadEnabled.set(state == Qt::Checked); + + CCrashSettings settings = m_crashDumpSettings.getThreadLocal(); + settings.setEnabled(state == Qt::Checked); + m_crashDumpSettings.set(settings); } } // ns diff --git a/src/blackgui/components/settingsadvancedcomponent.h b/src/blackgui/components/settingsadvancedcomponent.h index 5eb8c35b0..6488c1aff 100644 --- a/src/blackgui/components/settingsadvancedcomponent.h +++ b/src/blackgui/components/settingsadvancedcomponent.h @@ -20,8 +20,6 @@ #include #include -class QWidget; - namespace Ui { class CSettingsAdvancedComponent; } namespace BlackGui { @@ -43,7 +41,7 @@ namespace BlackGui void crashDumpUploadEnabledChanged(int state); QScopedPointer ui; - BlackMisc::CSetting m_crashDumpUploadEnabled { this }; + BlackMisc::CSetting m_crashDumpSettings { this }; }; } // ns } // ns