Skip to content

Commit

Permalink
Merge pull request #7583 from delroth/updater-crash
Browse files Browse the repository at this point in the history
Fix Updater crashes with new taskbar integration feature
  • Loading branch information
delroth committed Nov 22, 2018
2 parents 1805f51 + c9d5ac3 commit fe8854d
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions Source/Core/Updater/UI.cpp
Expand Up @@ -47,7 +47,16 @@ bool Init()
if (!window_handle) if (!window_handle)
return false; 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, label_handle = CreateWindow(L"STATIC", NULL, WS_VISIBLE | WS_CHILD, 5, 5, 500, 25, window_handle,
nullptr, nullptr, 0); nullptr, nullptr, 0);
Expand Down Expand Up @@ -93,7 +102,10 @@ void SetTotalMarquee(bool marquee)
SetWindowLong(total_progressbar_handle, GWL_STYLE, SetWindowLong(total_progressbar_handle, GWL_STYLE,
PROGRESSBAR_FLAGS | (marquee ? PBS_MARQUEE : 0)); PROGRESSBAR_FLAGS | (marquee ? PBS_MARQUEE : 0));
SendMessage(total_progressbar_handle, PBM_SETMARQUEE, 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() void ResetTotalProgress()
Expand All @@ -106,7 +118,10 @@ void SetTotalProgress(int current, int total)
{ {
SendMessage(total_progressbar_handle, PBM_SETRANGE32, 0, total); SendMessage(total_progressbar_handle, PBM_SETRANGE32, 0, total);
SendMessage(total_progressbar_handle, PBM_SETPOS, current, 0); 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) void SetCurrentMarquee(bool marquee)
Expand All @@ -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"A fatal error occured and the updater cannot continue:\n " + wide_text).c_str(),
L"Error", MB_ICONERROR); 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) void SetCurrentProgress(int current, int total)
Expand Down

0 comments on commit fe8854d

Please sign in to comment.