From 339d57b646f32fbd67dcf5d0352818c49a4c7870 Mon Sep 17 00:00:00 2001 From: Nicolas Mazzon Date: Wed, 1 Mar 2023 23:24:04 +0100 Subject: [PATCH] On Windows, check whether CoCreateInstance succeeds --- CHANGELOG.md | 1 + src/platform_impl/windows/window.rs | 14 ++++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dd511a8aab..67b8293c25 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ And please only add new entries to the top of this list, right below the `# Unre - Web: Added support for `Window::theme`. - On Wayland, fix rounding issues when doing resize. - On macOS, fix wrong focused state on startup. +- On Windows, fix crash on setting taskbar when using Visual Studio debugger. # 0.28.1 diff --git a/src/platform_impl/windows/window.rs b/src/platform_impl/windows/window.rs index fad480495c..21fa458e9d 100644 --- a/src/platform_impl/windows/window.rs +++ b/src/platform_impl/windows/window.rs @@ -1218,10 +1218,13 @@ unsafe fn taskbar_mark_fullscreen(handle: HWND, fullscreen: bool) { &IID_ITaskbarList2, &mut task_bar_list2 as *mut _ as *mut _, ); + if hr != S_OK { + // In visual studio retrieving the taskbar list fails + return; + } let hr_init = (*(*task_bar_list2).lpVtbl).parent.HrInit; - - if hr != S_OK || hr_init(task_bar_list2.cast()) != S_OK { + if hr_init(task_bar_list2.cast()) != S_OK { // In some old windows, the taskbar object could not be created, we just ignore it return; } @@ -1247,10 +1250,13 @@ pub(crate) unsafe fn set_skip_taskbar(hwnd: HWND, skip: bool) { &IID_ITaskbarList, &mut task_bar_list as *mut _ as *mut _, ); + if hr != S_OK { + // In visual studio retrieving the taskbar list fails + return; + } let hr_init = (*(*task_bar_list).lpVtbl).HrInit; - - if hr != S_OK || hr_init(task_bar_list.cast()) != S_OK { + if hr_init(task_bar_list.cast()) != S_OK { // In some old windows, the taskbar object could not be created, we just ignore it return; }