From af07f8853a70756f778272b9ec9336954a3bee66 Mon Sep 17 00:00:00 2001
From: Gary Talent <gary@drinkingtea.net>
Date: Sat, 29 Mar 2025 14:45:32 -0500
Subject: [PATCH] Fix SettingsDialog to do validity check when OK is pressed

---
 src/settingsdialog.cpp | 10 ++++++----
 src/settingsdialog.hpp |  3 ++-
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/settingsdialog.cpp b/src/settingsdialog.cpp
index ecd3f70..39ff931 100644
--- a/src/settingsdialog.cpp
+++ b/src/settingsdialog.cpp
@@ -205,12 +205,12 @@ QWidget *SettingsDialog::setupButtons(QWidget *parent) {
 	return root;
 }
 
-void SettingsDialog::handleApply() {
+int SettingsDialog::handleApply() {
 	QSettings settings;
 	QVector<View> views;
 	auto const viewsErr = collectViews(views);
 	if (viewsErr) {
-		return;
+        return -1;
 	}
 	setViews(settings, views);
 	setCameraConnectionData(settings, {
@@ -227,11 +227,13 @@ void SettingsDialog::handleApply() {
 	});
 	collectVideoConfig();
 	setVideoConfig(settings, m_videoConfig);
+    return 0;
 }
 
 void SettingsDialog::handleOK() {
-	handleApply();
-	accept();
+    if (handleApply() == 0) {
+        accept();
+    }
 }
 
 void SettingsDialog::setupViewRow(int row, View const&view) {
diff --git a/src/settingsdialog.hpp b/src/settingsdialog.hpp
index 6a1c728..9de8361 100644
--- a/src/settingsdialog.hpp
+++ b/src/settingsdialog.hpp
@@ -38,7 +38,8 @@ class SettingsDialog: public QDialog {
 		QWidget *setupViewConfig(QWidget *parent);
 		QWidget *setupImageConfig(QWidget *parent);
 		QWidget *setupButtons(QWidget *parent);
-		void handleApply();
+        [[nodiscard]]
+        int handleApply();
 		void handleOK();
 		void setupViewRow(int row, View const&view = {});
 		/**