Make crash dump uploading configurable

refs #490
This commit is contained in:
Roland Winklmeier
2016-07-29 16:56:43 +02:00
parent e47aec223e
commit 78eeecf052
7 changed files with 205 additions and 3 deletions

View File

@@ -1005,8 +1005,7 @@ namespace BlackCore
}
CUrl serverUrl;
if (CBuildConfig::isReleaseBuild()) { serverUrl = getGlobalSetup().getCrashreportServerUrl(); }
serverUrl = getGlobalSetup().getCrashreportServerUrl();
std::map<std::string, std::string> annotations;
// Caliper (mini-breakpad-server) annotations
@@ -1015,7 +1014,7 @@ namespace BlackCore
m_crashReportDatabase = CrashReportDatabase::Initialize(qstringToFilePath(database));
auto settings = m_crashReportDatabase->GetSettings();
settings->SetUploadsEnabled(true);
settings->SetUploadsEnabled(CBuildConfig::isReleaseBuild() && m_crashDumpUploadEnabled.getThreadLocal());
m_crashpadClient = std::make_unique<CrashpadClient>();
m_crashpadClient->StartHandler(qstringToFilePath(handler), qstringToFilePath(database),
serverUrl.getFullUrl().toStdString(), annotations, {}, false);
@@ -1023,4 +1022,13 @@ namespace BlackCore
#endif
}
void CApplication::crashDumpUploadEnabledChanged()
{
#ifdef BLACK_USE_CRASHPAD
if (!m_crashReportDatabase) { return; }
auto settings = m_crashReportDatabase->GetSettings();
settings->SetUploadsEnabled(CBuildConfig::isReleaseBuild() && m_crashDumpUploadEnabled.getThreadLocal());
#endif
}
} // ns

View File

@@ -30,6 +30,7 @@
#include "blackcore/data/globalsetup.h"
#include "blackcore/data/updateinfo.h"
#include "blackcore/db/databasereaderconfig.h"
#include "blackcore/application/applicationsettings.h"
#include "blackcore/webreaderflags.h"
#include "blackmisc/network/url.h"
#include "blackmisc/network/urllist.h"
@@ -414,6 +415,8 @@ namespace BlackCore
void initCrashHandler();
void crashDumpUploadEnabledChanged();
QScopedPointer<CCoreFacade> m_coreFacade; //!< core facade if any
QScopedPointer<CSetupReader> m_setupReader; //!< setup reader
QScopedPointer<CWebDataServices> m_webDataServices; //!< web data services
@@ -434,8 +437,11 @@ namespace BlackCore
bool m_unitTest = false; //!< is UNIT test
bool m_autoSaveSettings = true;//!< automatically saving all settings
#ifdef BLACK_USE_CRASHPAD
std::unique_ptr<crashpad::CrashpadClient> m_crashpadClient;
std::unique_ptr<crashpad::CrashReportDatabase> m_crashReportDatabase;
BlackMisc::CSetting<BlackCore::Application::TCrashDumpUploadEnabled> m_crashDumpUploadEnabled { this, &CApplication::crashDumpUploadEnabledChanged };
#endif
};
} // namespace

View File

@@ -91,6 +91,17 @@ namespace BlackCore
};
}
};
//! Uploading of crash dumps is enabled or disabled
struct TCrashDumpUploadEnabled : public BlackMisc::TSettingTrait<bool>
{
//! \copydoc BlackCore::TSettingTrait::key
static const char *key() { return "application/crashdumpuploadenabled"; }
//! \copydoc BlackCore::TSettingTrait::defaultValue
static bool defaultValue() { return true; }
};
} // ns
} // ns

View File

@@ -0,0 +1,43 @@
/* Copyright (C) 2015
* swift project Community / Contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
* including this file, may be copied, modified, propagated, or distributed except according to the terms
* contained in the LICENSE file.
*/
#include "blackgui/components/settingsadvancedcomponent.h"
#include "ui_settingsadvancedcomponent.h"
using namespace BlackMisc;
namespace BlackGui
{
namespace Components
{
CSettingsAdvancedComponent::CSettingsAdvancedComponent(QWidget *parent) :
QFrame(parent),
ui(new Ui::CSettingsAdvancedComponent)
{
ui->setupUi(this);
ui->m_crashDumpsUpload->setChecked(m_crashDumpUploadEnabled.getThreadLocal());
connect(ui->m_crashDumpsUpload, &QCheckBox::stateChanged, this, &CSettingsAdvancedComponent::crashDumpUploadEnabledChanged);
}
CSettingsAdvancedComponent::~CSettingsAdvancedComponent()
{
}
void CSettingsAdvancedComponent::crashDumpUploadEnabledChanged(int state)
{
auto text = ui->m_crashDumpsUpload->text();
if (!text.endsWith("(restart needed)"))
{
ui->m_crashDumpsUpload->setText(ui->m_crashDumpsUpload->text() + " (restart needed)");
}
m_crashDumpUploadEnabled.set(state == Qt::Checked);
}
} // ns
} // ns

View File

@@ -0,0 +1,54 @@
/* Copyright (C) 2015
* swift project Community / Contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
* including this file, may be copied, modified, propagated, or distributed except according to the terms
* contained in the LICENSE file.
*/
//! \file
#ifndef BLACKGUI_COMPONENTS_SETTINGSGENERALCOMPONENT_H
#define BLACKGUI_COMPONENTS_SETTINGSGENERALCOMPONENT_H
#include "blackgui/blackguiexport.h"
#include "blackcore/application/applicationsettings.h"
#include "blackmisc/settingscache.h"
#include <QFrame>
#include <QObject>
#include <QScopedPointer>
class QWidget;
namespace Ui { class CSettingsAdvancedComponent; }
namespace BlackGui
{
namespace Components
{
//! Configure general settings
class BLACKGUI_EXPORT CSettingsAdvancedComponent :
public QFrame
{
Q_OBJECT
public:
//! Constructor
CSettingsAdvancedComponent(QWidget *parent = nullptr);
//! Destructor
~CSettingsAdvancedComponent();
private:
void crashDumpUploadEnabledChanged(int state);
QScopedPointer<Ui::CSettingsAdvancedComponent> ui;
BlackMisc::CSetting<BlackCore::Application::TCrashDumpUploadEnabled> m_crashDumpUploadEnabled { this };
};
} // ns
} // ns
#endif // guard

View File

@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CSettingsAdvancedComponent</class>
<widget class="QFrame" name="CSettingsAdvancedComponent">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>193</height>
</rect>
</property>
<property name="windowTitle">
<string>sample_hotkeys</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>1</number>
</property>
<property name="topMargin">
<number>1</number>
</property>
<property name="rightMargin">
<number>1</number>
</property>
<item row="0" column="0">
<widget class="QCheckBox" name="m_crashDumpsUpload">
<property name="text">
<string>Upload crash dumps</string>
</property>
</widget>
</item>
<item row="1" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>

View File

@@ -687,6 +687,23 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="tb_SettingsAdvanced">
<attribute name="title">
<string>Advanced</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="BlackGui::Components::CSettingsAdvancedComponent" name="comp_SettingsAdvancedComponent">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<customwidgets>
<customwidget>
@@ -695,6 +712,12 @@
<header>blackgui/components/audiosetupcomponent.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>BlackGui::Components::CSettingsAdvancedComponent</class>
<extends>QFrame</extends>
<header>blackgui/components/settingsadvancedcomponent.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>BlackGui::Components::CSettingsSimulatorComponent</class>
<extends>QFrame</extends>