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.
This commit is contained in:
Richard Stanway 2017-08-09 01:11:35 +02:00
parent c8c6f07618
commit e59f969633
No known key found for this signature in database
GPG Key ID: AAC1E5265D71B3FD

View File

@ -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;