From 4660a3d92bde12672594755b4e5b1a6c7c94e946 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Mon, 28 Oct 2024 13:11:49 +0100 Subject: [PATCH] Crashpad: Make the test crashbutton more accessible Add the button to the settings layout and show it depending on the environment variable `QTC_SHOW_CRASHBUTTON` instead of a setting that needs to be manually added to the settings file. Change-Id: I130b1c061a8d1448d7238f1e3c0714116195c1c1 Reviewed-by: Tim Jenssen --- src/plugins/coreplugin/systemsettings.cpp | 26 +++++++++++------------ src/plugins/coreplugin/systemsettings.h | 1 - 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/plugins/coreplugin/systemsettings.cpp b/src/plugins/coreplugin/systemsettings.cpp index 4a743ada92d..b89734d7567 100644 --- a/src/plugins/coreplugin/systemsettings.cpp +++ b/src/plugins/coreplugin/systemsettings.cpp @@ -145,7 +145,6 @@ SystemSettings::SystemSettings() Tr::tr("Allow crashes to be automatically reported. Collected reports are " "used for the sole purpose of fixing bugs.")); - showCrashButton.setSettingsKey("ShowCrashButton"); #endif readSettings(); @@ -239,9 +238,19 @@ public: .arg(appInfo().crashReports.toUserOutput()); m_clearCrashReportsButton->setToolTip(toolTip); m_crashReportsSizeText->setToolTip(toolTip); - grid.addRow( - {s.enableCrashReporting, - Row{m_clearCrashReportsButton, m_crashReportsSizeText, helpCrashReportingButton, st}}); + Row crashDetails + = Row{m_clearCrashReportsButton, m_crashReportsSizeText, helpCrashReportingButton, st}; + if (qtcEnvironmentVariableIsSet("QTC_SHOW_CRASHBUTTON")) { + auto crashButton = new QPushButton("CRASH!!!"); + connect(crashButton, &QPushButton::clicked, [] { + // do a real crash + volatile int *a = reinterpret_cast(NULL); + *a = 1; + }); + crashDetails.addItem(crashButton); + } + grid.addRow({s.enableCrashReporting, crashDetails}); + #endif Column { @@ -267,15 +276,6 @@ public: } #ifdef ENABLE_CRASHPAD - if (s.showCrashButton()) { - auto crashButton = new QPushButton("CRASH!!!"); - crashButton->show(); - connect(crashButton, &QPushButton::clicked, [] { - // do a real crash - volatile int* a = reinterpret_cast(NULL); *a = 1; - }); - } - connect(helpCrashReportingButton, &QAbstractButton::clicked, this, [this] { showHelpDialog(Tr::tr("Crash Reporting"), CorePlugin::msgCrashpadInformation()); }); diff --git a/src/plugins/coreplugin/systemsettings.h b/src/plugins/coreplugin/systemsettings.h index 1c4bdfc9e37..05c4d152a4f 100644 --- a/src/plugins/coreplugin/systemsettings.h +++ b/src/plugins/coreplugin/systemsettings.h @@ -33,7 +33,6 @@ public: #ifdef ENABLE_CRASHPAD Utils::BoolAspect enableCrashReporting{this}; - Utils::BoolAspect showCrashButton{this}; #endif Utils::BoolAspect askBeforeExit{this};