From 74ae7149829d316ce15a478e32d87e7b55b0c9eb Mon Sep 17 00:00:00 2001 From: Ray Molenkamp Date: Wed, 15 Nov 2023 08:54:38 -0700 Subject: [PATCH 1/2] Fix #114906 invalid reuse of shell_link shell_link was being reused, sometimes returning the previous data causing links that were not ours to be updated. --- .../blenlib/intern/winstuff_registration.cc | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/source/blender/blenlib/intern/winstuff_registration.cc b/source/blender/blenlib/intern/winstuff_registration.cc index f18319b2f08..e5323a42d7e 100644 --- a/source/blender/blenlib/intern/winstuff_registration.cc +++ b/source/blender/blenlib/intern/winstuff_registration.cc @@ -59,17 +59,19 @@ bool BLI_windows_update_pinned_launcher(const char *launcher_path) std::wstring search_path = quick_launch_folder_path; CoTaskMemFree(quick_launch_folder_path); - Microsoft::WRL::ComPtr shell_link; - if (CoCreateInstance(__uuidof(ShellLink), NULL, CLSCTX_ALL, IID_PPV_ARGS(&shell_link)) != S_OK) { - return false; - } - - Microsoft::WRL::ComPtr persist_file; - if (shell_link.As(&persist_file) != S_OK) { - return false; - } - for (auto const &dir_entry : std::filesystem::recursive_directory_iterator(search_path)) { + + Microsoft::WRL::ComPtr shell_link; + if (CoCreateInstance(__uuidof(ShellLink), NULL, CLSCTX_ALL, IID_PPV_ARGS(&shell_link)) != S_OK) + { + return false; + } + + Microsoft::WRL::ComPtr persist_file; + if (shell_link.As(&persist_file) != S_OK) { + return false; + } + if (persist_file->Load(dir_entry.path().c_str(), STGM_READWRITE) != S_OK) { continue; } -- 2.30.2 From 3fd1476459a8f5fd3056a601e891ed9e7e7b6f04 Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Wed, 15 Nov 2023 09:27:57 -0800 Subject: [PATCH 2/2] Testing that the PROPVARIANT is not empty --- source/blender/blenlib/intern/winstuff_registration.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/blenlib/intern/winstuff_registration.cc b/source/blender/blenlib/intern/winstuff_registration.cc index e5323a42d7e..6257479f2ca 100644 --- a/source/blender/blenlib/intern/winstuff_registration.cc +++ b/source/blender/blenlib/intern/winstuff_registration.cc @@ -85,7 +85,7 @@ bool BLI_windows_update_pinned_launcher(const char *launcher_path) PROPVARIANT app_model; PropVariantInit(&app_model); if (property_store->GetValue(PKEY_AppUserModel_ID, &app_model) == S_OK) { - if (std::wstring(BLENDER_WIN_APPID_16) == app_model.bstrVal) { + if (app_model.vt == VT_LPWSTR && std::wstring(BLENDER_WIN_APPID_16) == app_model.pwszVal) { shell_link->SetPath(launcher_path_w); persist_file->Save(NULL, TRUE); } -- 2.30.2