From e59f96963367d9948520fa43335cb9b488d99b49 Mon Sep 17 00:00:00 2001 From: Richard Stanway Date: Wed, 9 Aug 2017 01:11:35 +0200 Subject: [PATCH] UI/updater: Restart progress bar when installing updates When updating large files such as libcef, the patching process can take a decent amount of time. Previously the progress bar would remain at 100% after completing the downloads, so the user may think the updater has frozen. Now it shows the process of the install / patching process. --- UI/win-update/updater/updater.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/UI/win-update/updater/updater.cpp b/UI/win-update/updater/updater.cpp index 10f850d38..80d999184 100644 --- a/UI/win-update/updater/updater.cpp +++ b/UI/win-update/updater/updater.cpp @@ -1211,9 +1211,25 @@ static bool Update(wchar_t *cmdLine) /* ------------------------------------- * * Install updates */ + int updatesInstalled = 0; + int lastPosition = 0; + + SendDlgItemMessage(hwndMain, IDC_PROGRESS, + PBM_SETPOS, 0, 0); + for (update_t &update : updates) { - if (!UpdateFile(update)) + if (!UpdateFile(update)) { return false; + } else { + updatesInstalled++; + int position = (int)(((float)updatesInstalled / + (float)completedUpdates) * 100.0f); + if (position > lastPosition) { + lastPosition = position; + SendDlgItemMessage(hwndMain, IDC_PROGRESS, + PBM_SETPOS, position, 0); + } + } } /* If we get here, all updates installed successfully so we can purge @@ -1227,6 +1243,9 @@ static bool Update(wchar_t *cmdLine) DeleteFile(update.tempPath.c_str()); } + SendDlgItemMessage(hwndMain, IDC_PROGRESS, + PBM_SETPOS, 100, 0); + Status(L"Update complete."); SetDlgItemText(hwndMain, IDC_BUTTON, L"Launch OBS"); return true;