From 7e940e515bf4c1b2eb8a00a5f98fe59e795110b3 Mon Sep 17 00:00:00 2001 From: WarmUpTill <19472752+WarmUpTill@users.noreply.github.com> Date: Tue, 31 Mar 2026 20:24:16 +0200 Subject: [PATCH] Add option to suppress crash dialog --- data/locale/en-US.ini | 2 + forms/advanced-scene-switcher.ui | 7 ++++ lib/advanced-scene-switcher.hpp | 1 + lib/general.cpp | 11 ++++++ lib/utils/crash-handler.cpp | 67 +++++++++++++++++++++++++++++--- lib/utils/crash-handler.hpp | 3 ++ 6 files changed, 85 insertions(+), 6 deletions(-) diff --git a/data/locale/en-US.ini b/data/locale/en-US.ini index 6d842c2f..ad63de66 100644 --- a/data/locale/en-US.ini +++ b/data/locale/en-US.ini @@ -40,6 +40,7 @@ AdvSceneSwitcher.generalTab.generalBehavior.showTrayNotifications="Show system t AdvSceneSwitcher.generalTab.generalBehavior.disableUIHints="Disable UI hints" AdvSceneSwitcher.generalTab.generalBehavior.comboBoxFilterDisable="Disable filtering by typing in drop down menus" AdvSceneSwitcher.generalTab.generalBehavior.warnPluginLoadFailure="Display warning if plugins cannot be loaded" +AdvSceneSwitcher.generalTab.generalBehavior.suppressCrashRecoveryDialog="Do not ask to keep the plugin stopped after an unclean shutdown" AdvSceneSwitcher.generalTab.generalBehavior.warnPluginLoadFailureMessage="Loading of the following plugin libraries was unsuccessful, which could result in some Advanced Scene Switcher functions not being available:%1Check the OBS logs for details.
This message can be disabled on the General tab." AdvSceneSwitcher.generalTab.generalBehavior.warnCorruptedInstallMessage="The plugin installation seems to be corrupted and might crash!\nPlease make sure the plugin was installed correctly!" AdvSceneSwitcher.generalTab.generalBehavior.hideLegacyTabs="Hide tabs which can be represented via macros" @@ -1432,6 +1433,7 @@ AdvSceneSwitcher.askBackup="Detected a new version of the Advanced Scene Switche AdvSceneSwitcher.askForMacro="Select macro{{macroSelection}}" AdvSceneSwitcher.crashDetected="OBS did not shut down cleanly (for example, due to a crash or freeze).\n\nThe Advanced Scene Switcher plugin would normally start automatically.\nWould you like to keep it stopped for now?" +AdvSceneSwitcher.crashDetected.suppressCheckbox="Do not show this dialog again" AdvSceneSwitcher.close="Close" AdvSceneSwitcher.browse="Browse" diff --git a/forms/advanced-scene-switcher.ui b/forms/advanced-scene-switcher.ui index 64327853..065e4ec3 100644 --- a/forms/advanced-scene-switcher.ui +++ b/forms/advanced-scene-switcher.ui @@ -251,6 +251,13 @@ + + + + AdvSceneSwitcher.generalTab.generalBehavior.suppressCrashRecoveryDialog + + + diff --git a/lib/advanced-scene-switcher.hpp b/lib/advanced-scene-switcher.hpp index a932c267..47651ab4 100644 --- a/lib/advanced-scene-switcher.hpp +++ b/lib/advanced-scene-switcher.hpp @@ -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(); diff --git a/lib/general.cpp b/lib/general.cpp index 327e2e43..cbabb3a8 100644 --- a/lib/general.cpp +++ b/lib/general.cpp @@ -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); diff --git a/lib/utils/crash-handler.cpp b/lib/utils/crash-handler.cpp index e2cc89e4..676cda44 100644 --- a/lib/utils/crash-handler.cpp +++ b/lib/utils/crash-handler.cpp @@ -2,17 +2,18 @@ #include "log-helper.hpp" #include "obs-module-helper.hpp" #include "plugin-state-helpers.hpp" -#include "ui-helpers.hpp" #include #include +#include +#include +#include #include #include +#include #include -#include - -#include +#include 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(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. diff --git a/lib/utils/crash-handler.hpp b/lib/utils/crash-handler.hpp index f02fe2b3..a9065b1d 100644 --- a/lib/utils/crash-handler.hpp +++ b/lib/utils/crash-handler.hpp @@ -4,4 +4,7 @@ namespace advss { bool ShouldSkipPluginStartOnUncleanShutdown(); +bool GetSuppressCrashDialog(); +void SetSuppressCrashDialog(bool suppress); + } // namespace advss