mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-08-11 19:58:49 -05:00
Add option to suppress crash dialog
Some checks are pending
debian-build / build (push) Waiting to run
Check locale / ubuntu64 (push) Waiting to run
Push to master / Check Formatting 🔍 (push) Waiting to run
Push to master / Build Project 🧱 (push) Waiting to run
Push to master / Create Release 🛫 (push) Blocked by required conditions
Some checks are pending
debian-build / build (push) Waiting to run
Check locale / ubuntu64 (push) Waiting to run
Push to master / Check Formatting 🔍 (push) Waiting to run
Push to master / Build Project 🧱 (push) Waiting to run
Push to master / Create Release 🛫 (push) Blocked by required conditions
This commit is contained in:
@@ -66,6 +66,7 @@ public slots:
|
||||
void on_uiHintsDisable_stateChanged(int state);
|
||||
void on_disableComboBoxFilter_stateChanged(int state);
|
||||
void on_warnPluginLoadFailure_stateChanged(int state);
|
||||
void on_suppressCrashRecoveryDialog_stateChanged(int state);
|
||||
void on_hideLegacyTabs_stateChanged(int state);
|
||||
void on_priorityUp_clicked();
|
||||
void on_priorityDown_clicked();
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "advanced-scene-switcher.hpp"
|
||||
#include "crash-handler.hpp"
|
||||
#include "file-selection.hpp"
|
||||
#include "filter-combo-box.hpp"
|
||||
#include "first-run-wizard.hpp"
|
||||
@@ -194,6 +195,15 @@ void AdvSceneSwitcher::on_warnPluginLoadFailure_stateChanged(int state)
|
||||
switcher->warnPluginLoadFailure = state;
|
||||
}
|
||||
|
||||
void AdvSceneSwitcher::on_suppressCrashRecoveryDialog_stateChanged(int state)
|
||||
{
|
||||
if (loading) {
|
||||
return;
|
||||
}
|
||||
|
||||
SetSuppressCrashDialog(state);
|
||||
}
|
||||
|
||||
static bool isLegacyTab(const QString &name)
|
||||
{
|
||||
return name == obs_module_text(
|
||||
@@ -946,6 +956,7 @@ void AdvSceneSwitcher::SetupGeneralTab()
|
||||
FilterComboBox::SetFilterBehaviourEnabled(
|
||||
!switcher->disableFilterComboboxFilter);
|
||||
ui->warnPluginLoadFailure->setChecked(switcher->warnPluginLoadFailure);
|
||||
ui->suppressCrashRecoveryDialog->setChecked(GetSuppressCrashDialog());
|
||||
ui->hideLegacyTabs->setChecked(switcher->hideLegacyTabs);
|
||||
|
||||
populatePriorityFunctionList(ui->priorityList);
|
||||
|
||||
@@ -2,17 +2,18 @@
|
||||
#include "log-helper.hpp"
|
||||
#include "obs-module-helper.hpp"
|
||||
#include "plugin-state-helpers.hpp"
|
||||
#include "ui-helpers.hpp"
|
||||
|
||||
#include <obs-frontend-api.h>
|
||||
#include <obs-module.h>
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QDialog>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QLabel>
|
||||
#include <QMainWindow>
|
||||
#include <QTimer>
|
||||
|
||||
#include <thread>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
namespace advss {
|
||||
|
||||
@@ -25,10 +26,29 @@ static constexpr bool handleUncleanShutdown = true;
|
||||
#endif
|
||||
|
||||
static bool wasCleanShutdown = false;
|
||||
static bool suppressCrashDialog = false;
|
||||
|
||||
bool GetSuppressCrashDialog()
|
||||
{
|
||||
return suppressCrashDialog;
|
||||
}
|
||||
|
||||
void SetSuppressCrashDialog(bool suppress)
|
||||
{
|
||||
suppressCrashDialog = suppress;
|
||||
}
|
||||
|
||||
static void setup();
|
||||
static bool setupDone = []() {
|
||||
AddPluginInitStep(setup);
|
||||
AddSaveStep([](obs_data_t *obj) {
|
||||
obs_data_set_bool(obj, "suppressCrashDialog",
|
||||
suppressCrashDialog);
|
||||
});
|
||||
AddLoadStep([](obs_data_t *obj) {
|
||||
suppressCrashDialog =
|
||||
obs_data_get_bool(obj, "suppressCrashDialog");
|
||||
});
|
||||
return true;
|
||||
}();
|
||||
|
||||
@@ -108,8 +128,39 @@ static bool wasUncleanShutdown()
|
||||
|
||||
static void askForStartupSkip()
|
||||
{
|
||||
bool skipStart = DisplayMessage(
|
||||
obs_module_text("AdvSceneSwitcher.crashDetected"), true, false);
|
||||
auto mainWindow =
|
||||
static_cast<QMainWindow *>(obs_frontend_get_main_window());
|
||||
auto dialog = new QDialog(mainWindow);
|
||||
dialog->setWindowTitle(obs_module_text("AdvSceneSwitcher.windowTitle"));
|
||||
dialog->setWindowFlags(dialog->windowFlags() &
|
||||
~Qt::WindowContextHelpButtonHint);
|
||||
|
||||
auto layout = new QVBoxLayout(dialog);
|
||||
auto label = new QLabel(
|
||||
obs_module_text("AdvSceneSwitcher.crashDetected"), dialog);
|
||||
label->setWordWrap(true);
|
||||
layout->addWidget(label);
|
||||
|
||||
auto checkbox = new QCheckBox(
|
||||
obs_module_text(
|
||||
"AdvSceneSwitcher.crashDetected.suppressCheckbox"),
|
||||
dialog);
|
||||
layout->addWidget(checkbox);
|
||||
|
||||
auto buttonbox = new QDialogButtonBox(
|
||||
QDialogButtonBox::Yes | QDialogButtonBox::No, dialog);
|
||||
QObject::connect(buttonbox, &QDialogButtonBox::accepted, dialog,
|
||||
&QDialog::accept);
|
||||
QObject::connect(buttonbox, &QDialogButtonBox::rejected, dialog,
|
||||
&QDialog::reject);
|
||||
layout->addWidget(buttonbox);
|
||||
|
||||
dialog->setLayout(layout);
|
||||
|
||||
bool skipStart = dialog->exec() == QDialog::Accepted;
|
||||
suppressCrashDialog = checkbox->isChecked();
|
||||
dialog->deleteLater();
|
||||
|
||||
if (!skipStart) {
|
||||
StartPlugin();
|
||||
}
|
||||
@@ -121,6 +172,10 @@ bool ShouldSkipPluginStartOnUncleanShutdown()
|
||||
return false;
|
||||
}
|
||||
|
||||
if (suppressCrashDialog) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// This function is called while the plugin settings are being loaded.
|
||||
// Blocking at this stage can cause issues such as OBS failing to start
|
||||
// or crashing.
|
||||
|
||||
@@ -4,4 +4,7 @@ namespace advss {
|
||||
|
||||
bool ShouldSkipPluginStartOnUncleanShutdown();
|
||||
|
||||
bool GetSuppressCrashDialog();
|
||||
void SetSuppressCrashDialog(bool suppress);
|
||||
|
||||
} // namespace advss
|
||||
|
||||
Reference in New Issue
Block a user