Harden settings side effects

Signed-off-by: Loren Eteval <loren.eteval@proton.me>
This commit is contained in:
Loren Eteval
2026-08-19 11:06:44 +08:00
parent 936a5b3664
commit 0b4c6f095e
+10 -5
View File
@@ -217,15 +217,20 @@ class SettingsController:
cls._setBinary('HideDockIcon', enabled)
@classmethod
def setStartupOnBoot(cls, enabled: bool):
"""Apply the platform startup registration preference."""
def setStartupOnBoot(cls, enabled: bool) -> bool:
"""Persist startup preference only after host registration succeeds."""
if enabled:
StartupOnBoot.on_()
success = StartupOnBoot.on_()
else:
StartupOnBoot.off()
success = StartupOnBoot.off()
if not success:
return False
cls._setBinary('StartupOnBoot', enabled)
return True
@classmethod
def setPowerSaveMode(cls, enabled: bool):
"""Persist power-saving behavior for the next connection."""
@@ -290,7 +295,7 @@ class SettingsController:
cls._setBinary(METRICS_COLLECTION_SETTING, enabled)
try:
AppMainWindow().trafficStatsManager.setCollectionEnabled(enabled)
AppTrafficStatsManager().setCollectionEnabled(enabled)
except (AttributeError, RuntimeError):
pass