From 10a2ae96b876245ff7492360b7a555e1ce6807e3 Mon Sep 17 00:00:00 2001 From: Extremesecrecy <10959169+extremesecrecy@users.noreply.github.com> Date: Sun, 27 Jul 2025 10:36:42 -0700 Subject: [PATCH] Warning Fix, added comments 2 Warning handler was causing the ok not to function correctly. --- vite/src/pipedal/JackServerSettingsDialog.tsx | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/vite/src/pipedal/JackServerSettingsDialog.tsx b/vite/src/pipedal/JackServerSettingsDialog.tsx index 036dcf5..6c9d262 100644 --- a/vite/src/pipedal/JackServerSettingsDialog.tsx +++ b/vite/src/pipedal/JackServerSettingsDialog.tsx @@ -322,6 +322,9 @@ const JackServerSettingsDialog = withStyles( statusTimer?: number = undefined; suppressDeviceWarning: boolean; + /** + * Copy of the settings when the dialog is opened. Pressing Apply only tests these settings temporarily. Closing the dialog without OK re-applies the saved copy so the audio driver returns to its previous configuration. + */ originalJackServerSettings?: JackServerSettings; getFullScreen() { @@ -470,9 +473,15 @@ const JackServerSettingsDialog = withStyles( } componentWillUnmount() { - super.componentWillUnmount(); + super.componentWillUnmount(); this.mounted = false; - this.stopStatusTimer(); + this.stopStatusTimer(); + if (this.originalJackServerSettings) { + // Revert any unapplied changes when the dialog is unmounted + this.model.applyJackServerSettings(this.originalJackServerSettings); + this.model.setJackServerSettings(this.originalJackServerSettings); + this.originalJackServerSettings = undefined; + } @@ -582,7 +591,14 @@ const JackServerSettingsDialog = withStyles( this.setState({ showDeviceWarning: false, dontShowWarningAgain: false }, () => { let s = this.state.jackServerSettings.clone(); s.valid = true; - this.props.onApply(s); + // Accept the new settings so the dialog won't revert them on close + this.originalJackServerSettings = undefined; + // Apply and persist the settings just like the OK handler + this.model.applyJackServerSettings(s); + this.model.setJackServerSettings(s); + if (this.props.onApply) { + this.props.onApply(s); + } }); } handleWarningCancel() {