diff --git a/Source/Core/Updater/UI.cpp b/Source/Core/Updater/UI.cpp index ed4aab9196..dc90758036 100644 --- a/Source/Core/Updater/UI.cpp +++ b/Source/Core/Updater/UI.cpp @@ -47,7 +47,16 @@ bool Init() if (!window_handle) return false; - CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&taskbar_list)); + if (FAILED(CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, + IID_PPV_ARGS(&taskbar_list)))) + { + taskbar_list = nullptr; + } + if (taskbar_list && FAILED(taskbar_list->HrInit())) + { + taskbar_list->Release(); + taskbar_list = nullptr; + } label_handle = CreateWindow(L"STATIC", NULL, WS_VISIBLE | WS_CHILD, 5, 5, 500, 25, window_handle, nullptr, nullptr, 0); @@ -93,7 +102,10 @@ void SetTotalMarquee(bool marquee) SetWindowLong(total_progressbar_handle, GWL_STYLE, PROGRESSBAR_FLAGS | (marquee ? PBS_MARQUEE : 0)); SendMessage(total_progressbar_handle, PBM_SETMARQUEE, marquee, 0); - taskbar_list->SetProgressState(window_handle, marquee ? TBPF_INDETERMINATE : TBPF_NORMAL); + if (taskbar_list) + { + taskbar_list->SetProgressState(window_handle, marquee ? TBPF_INDETERMINATE : TBPF_NORMAL); + } } void ResetTotalProgress() @@ -106,7 +118,10 @@ void SetTotalProgress(int current, int total) { SendMessage(total_progressbar_handle, PBM_SETRANGE32, 0, total); SendMessage(total_progressbar_handle, PBM_SETPOS, current, 0); - taskbar_list->SetProgressValue(window_handle, current, total); + if (taskbar_list) + { + taskbar_list->SetProgressValue(window_handle, current, total); + } } void SetCurrentMarquee(bool marquee) @@ -130,7 +145,10 @@ void Error(const std::string& text) (L"A fatal error occured and the updater cannot continue:\n " + wide_text).c_str(), L"Error", MB_ICONERROR); - taskbar_list->SetProgressState(window_handle, TBPF_ERROR); + if (taskbar_list) + { + taskbar_list->SetProgressState(window_handle, TBPF_ERROR); + } } void SetCurrentProgress(int current, int total)