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 <tim.jenssen@qt.io>
This commit is contained in:
Eike Ziller
2024-10-28 13:11:49 +01:00
parent a39abf3298
commit 4660a3d92b
2 changed files with 13 additions and 14 deletions

View File

@@ -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<volatile int *>(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<volatile int *>(NULL); *a = 1;
});
}
connect(helpCrashReportingButton, &QAbstractButton::clicked, this, [this] {
showHelpDialog(Tr::tr("Crash Reporting"), CorePlugin::msgCrashpadInformation());
});

View File

@@ -33,7 +33,6 @@ public:
#ifdef ENABLE_CRASHPAD
Utils::BoolAspect enableCrashReporting{this};
Utils::BoolAspect showCrashButton{this};
#endif
Utils::BoolAspect askBeforeExit{this};