From b0dc518c8f1aad14abc0e525de683c700a12cdbd Mon Sep 17 00:00:00 2001 From: ShadowLemoon <119576779+ShadowLemoon@users.noreply.github.com> Date: Wed, 8 Apr 2026 17:10:34 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20revert=5Fsettings=E8=BF=94=E5=9B=9Efalse?= =?UTF-8?q?=E6=96=B9=E4=BE=BF=E8=B0=83=E7=94=A8=E6=96=B9=E9=87=8D=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../windows/display_device/settings.cpp | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/platform/windows/display_device/settings.cpp b/src/platform/windows/display_device/settings.cpp index b3bbe30bb..b91a7a5c7 100644 --- a/src/platform/windows/display_device/settings.cpp +++ b/src/platform/windows/display_device/settings.cpp @@ -981,18 +981,21 @@ namespace display_device { // 尝试恢复设置 bool data_updated { false }; bool success = try_revert_settings(*persistent_data, data_updated, skip_vdd_destroy); - if (!success) { + + if (success) { + // 恢复成功,清理持久化数据 + remove_file(filepath); + persistent_data = nullptr; + BOOST_LOG(info) << "显示设备配置已恢复"; + } + else { if (data_updated) { - save_settings(filepath, *persistent_data); // 忽略返回值 + save_settings(filepath, *persistent_data); // 保存部分恢复的状态以便重试 } BOOST_LOG(error) << "恢复显示设备设置失败!如有异常请尝试关闭基地显示器,或手动修改系统显示设置~"; } - // 清理持久化数据 - remove_file(filepath); - persistent_data = nullptr; - - // 释放音频数据 + // 不管成败都释放音频数据(串流已结束) if (reason != revert_reason_e::topology_switch) { if (audio_data) { BOOST_LOG(debug) << "释放捕获的音频接收器"; @@ -1000,9 +1003,7 @@ namespace display_device { } } - if (success) { - BOOST_LOG(info) << "显示设备配置已恢复"; - } + return success; } return true; }