From 764360c0f305c9e98205e98bf6f925a7d89469ed Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sun, 24 Mar 2019 19:15:35 -0700 Subject: [PATCH] Avoid doing non-trivial work in onCheckedChanged on settings page load --- app/gui/SettingsView.qml | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/app/gui/SettingsView.qml b/app/gui/SettingsView.qml index b974e82c..023c8d2a 100644 --- a/app/gui/SettingsView.qml +++ b/app/gui/SettingsView.qml @@ -685,11 +685,15 @@ Flickable { font.pointSize: 12 checked: prefs.unsupportedFps onCheckedChanged: { - prefs.unsupportedFps = checked + // This is called on init, so only do the work if we've + // actually changed the value. + if (prefs.unsupportedFps != checked) { + prefs.unsupportedFps = checked - // The selectable FPS values depend on whether - // this option is enabled or not - fpsComboBox.reinitialize() + // The selectable FPS values depend on whether + // this option is enabled or not + fpsComboBox.reinitialize() + } } } @@ -699,16 +703,20 @@ Flickable { font.pointSize: 12 checked: prefs.enableMdns onCheckedChanged: { - prefs.enableMdns = checked + // This is called on init, so only do the work if we've + // actually changed the value. + if (prefs.enableMdns != checked) { + prefs.enableMdns = checked - // We must save the updated preference to ensure - // ComputerManager can observe the change internally. - prefs.save() + // We must save the updated preference to ensure + // ComputerManager can observe the change internally. + prefs.save() - // Restart polling so the mDNS change takes effect - if (window.pollingActive) { - ComputerManager.stopPollingAsync() - ComputerManager.startPolling() + // Restart polling so the mDNS change takes effect + if (window.pollingActive) { + ComputerManager.stopPollingAsync() + ComputerManager.startPolling() + } } } }