From 150f26731c52cacd96d69e7cf419f4be484aea1e Mon Sep 17 00:00:00 2001 From: Jaime Bernardo Date: Tue, 13 Dec 2022 17:35:23 +0000 Subject: [PATCH] [VCM]Only use File Watchers if module is enabled (#22757) --- .../VideoConferenceModule.cpp | 17 ++++++++++++----- .../VideoConferenceModule.h | 4 ++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/modules/videoconference/VideoConferenceModule/VideoConferenceModule.cpp b/src/modules/videoconference/VideoConferenceModule/VideoConferenceModule.cpp index 7cee1e96da..8caa6db4eb 100644 --- a/src/modules/videoconference/VideoConferenceModule/VideoConferenceModule.cpp +++ b/src/modules/videoconference/VideoConferenceModule/VideoConferenceModule.cpp @@ -311,11 +311,7 @@ void VideoConferenceModule::onMicrophoneConfigurationChanged() } } -VideoConferenceModule::VideoConferenceModule() : - _generalSettingsWatcher{ PTSettingsHelper::get_powertoys_general_save_file_location(), [this] { - toolbar.scheduleGeneralSettingsUpdate(); - } }, - _moduleSettingsWatcher{ PTSettingsHelper::get_module_save_file_location(get_key()), [this] { toolbar.scheduleModuleSettingsUpdate(); } } +VideoConferenceModule::VideoConferenceModule() { init_settings(); _settingsUpdateChannel = @@ -524,6 +520,15 @@ void VideoConferenceModule::enable() { if (!_enabled) { + _generalSettingsWatcher = std::make_unique ( + PTSettingsHelper::get_powertoys_general_save_file_location(), [this] { + toolbar.scheduleGeneralSettingsUpdate(); + }); + _moduleSettingsWatcher = std::make_unique ( + PTSettingsHelper::get_module_save_file_location(get_key()), [this] { + toolbar.scheduleModuleSettingsUpdate(); + }); + toggleProxyCamRegistration(true); toolbar.setMicrophoneMute(getMicrophoneMuteState()); toolbar.setCameraMute(getVirtualCameraMuteState()); @@ -572,6 +577,8 @@ void VideoConferenceModule::disable() { if (_enabled) { + _generalSettingsWatcher.reset(); + _moduleSettingsWatcher.reset(); toggleProxyCamRegistration(false); if (hook_handle) { diff --git a/src/modules/videoconference/VideoConferenceModule/VideoConferenceModule.h b/src/modules/videoconference/VideoConferenceModule/VideoConferenceModule.h index 063f17adc9..d156c6493e 100644 --- a/src/modules/videoconference/VideoConferenceModule/VideoConferenceModule.h +++ b/src/modules/videoconference/VideoConferenceModule/VideoConferenceModule.h @@ -88,8 +88,8 @@ private: std::optional _imageOverlayChannel; std::optional _settingsUpdateChannel; - FileWatcher _generalSettingsWatcher; - FileWatcher _moduleSettingsWatcher; + std::unique_ptr _generalSettingsWatcher; + std::unique_ptr _moduleSettingsWatcher; static VideoConferenceSettings settings; static Toolbar toolbar;