mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
Ref T401, adjusted settings used in components
This commit is contained in:
@@ -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<CrashpadClient>();
|
||||
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
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "blackmisc/slot.h"
|
||||
#include "blackmisc/applicationinfolist.h"
|
||||
#include "blackmisc/statusmessagelist.h"
|
||||
#include "blackmisc/crashinfo.h"
|
||||
|
||||
#include <QByteArray>
|
||||
#include <QCommandLineOption>
|
||||
@@ -37,6 +38,7 @@
|
||||
#include <QList>
|
||||
#include <QObject>
|
||||
#include <QScopedPointer>
|
||||
#include <QByteArray>
|
||||
#include <atomic>
|
||||
#include <functional>
|
||||
|
||||
@@ -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<CCoreFacade> m_coreFacade; //!< core facade if any
|
||||
QScopedPointer<CSetupReader> m_setupReader; //!< setup reader
|
||||
QScopedPointer<CWebDataServices> m_webDataServices; //!< web data services
|
||||
QScopedPointer<BlackMisc::CFileLogger> m_fileLogger; //!< file logger
|
||||
QPointer<CCookieManager> 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<CCoreFacade> m_coreFacade; //!< core facade if any
|
||||
QScopedPointer<CSetupReader> m_setupReader; //!< setup reader
|
||||
QScopedPointer<CWebDataServices> m_webDataServices; //!< web data services
|
||||
QScopedPointer<BlackMisc::CFileLogger> m_fileLogger; //!< file logger
|
||||
QPointer<CCookieManager> 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<crashpad::CrashpadClient> m_crashpadClient;
|
||||
std::unique_ptr<crashpad::CrashReportDatabase> m_crashReportDatabase;
|
||||
BlackMisc::CSettingReadOnly<Application::TCrashDumpUploadEnabled> m_crashDumpUploadEnabled { this, &CApplication::crashDumpUploadEnabledChanged };
|
||||
BlackMisc::CSettingReadOnly<Application::TCrashDumpSettings> m_crashDumpSettings { this, &CApplication::onCrashDumpUploadEnabledChanged };
|
||||
#endif
|
||||
BlackMisc::CCrashInfo m_crashInfo; //!< info representing details
|
||||
|
||||
};
|
||||
} // namespace
|
||||
|
||||
|
||||
@@ -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 <QStringList>
|
||||
|
||||
namespace BlackCore
|
||||
@@ -76,16 +78,17 @@ namespace BlackCore
|
||||
};
|
||||
|
||||
//! Uploading of crash dumps is enabled or disabled
|
||||
struct TCrashDumpUploadEnabled : public BlackMisc::TSettingTrait<bool>
|
||||
//! \deprecated remove after changing to
|
||||
struct TCrashDumpSettings : public BlackMisc::TSettingTrait<BlackMisc::Settings::CCrashSettings>
|
||||
{
|
||||
//! \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
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace BlackGui
|
||||
void onAllowCrashDumps(bool checked);
|
||||
|
||||
QScopedPointer<Ui::CLegalInfoComponent> ui;
|
||||
BlackMisc::CSetting<BlackCore::Application::TCrashDumpUploadEnabled> m_crashDumpUploadEnabled { this };
|
||||
BlackMisc::CSetting<BlackCore::Application::TCrashDumpSettings> m_crashDumpSettings { this };
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -20,8 +20,6 @@
|
||||
#include <QObject>
|
||||
#include <QScopedPointer>
|
||||
|
||||
class QWidget;
|
||||
|
||||
namespace Ui { class CSettingsAdvancedComponent; }
|
||||
namespace BlackGui
|
||||
{
|
||||
@@ -43,7 +41,7 @@ namespace BlackGui
|
||||
void crashDumpUploadEnabledChanged(int state);
|
||||
|
||||
QScopedPointer<Ui::CSettingsAdvancedComponent> ui;
|
||||
BlackMisc::CSetting<BlackCore::Application::TCrashDumpUploadEnabled> m_crashDumpUploadEnabled { this };
|
||||
BlackMisc::CSetting<BlackCore::Application::TCrashDumpSettings> m_crashDumpSettings { this };
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
Reference in New Issue
Block a user