mirror of
https://github.com/reactos/reactos.git
synced 2024-09-28 21:44:31 +00:00
[0.4.14][RAPPS] Reduce the chance assert failed CORE-17649
This assertion happened whenever we canceled a download and was unhidden by 0.4.14-dev-1305-gbcd301d136
Fix picked from 0.4.15-dev-716-gc5e111427c
This commit is contained in:
parent
4295544598
commit
6ff325e77a
|
@ -139,6 +139,7 @@ public:
|
||||||
UINT uiPercentage = ((ULONGLONG) ulProgress * 100) / ulProgressMax;
|
UINT uiPercentage = ((ULONGLONG) ulProgress * 100) / ulProgressMax;
|
||||||
|
|
||||||
/* send the current progress to the progress bar */
|
/* send the current progress to the progress bar */
|
||||||
|
if (!IsWindow()) return;
|
||||||
SendMessage(PBM_SETPOS, uiPercentage, 0);
|
SendMessage(PBM_SETPOS, uiPercentage, 0);
|
||||||
|
|
||||||
/* format total download size */
|
/* format total download size */
|
||||||
|
@ -153,6 +154,7 @@ public:
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* send the current progress to the progress bar */
|
/* send the current progress to the progress bar */
|
||||||
|
if (!IsWindow()) return;
|
||||||
SendMessage(PBM_SETPOS, 0, 0);
|
SendMessage(PBM_SETPOS, 0, 0);
|
||||||
|
|
||||||
/* total size is not known, display only current size */
|
/* total size is not known, display only current size */
|
||||||
|
@ -160,6 +162,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
/* and finally display it */
|
/* and finally display it */
|
||||||
|
if (!IsWindow()) return;
|
||||||
SendMessage(WM_SETTEXT, 0, (LPARAM) ProgressText.GetString());
|
SendMessage(WM_SETTEXT, 0, (LPARAM) ProgressText.GetString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -482,8 +485,10 @@ VOID CDownloadManager::UpdateProgress(
|
||||||
{
|
{
|
||||||
HWND Item;
|
HWND Item;
|
||||||
|
|
||||||
|
if (!IsWindow(hDlg)) return;
|
||||||
ProgressBar.SetProgress(ulProgress, ulProgressMax);
|
ProgressBar.SetProgress(ulProgress, ulProgressMax);
|
||||||
|
|
||||||
|
if (!IsWindow(hDlg)) return;
|
||||||
Item = GetDlgItem(hDlg, IDC_DOWNLOAD_STATUS);
|
Item = GetDlgItem(hDlg, IDC_DOWNLOAD_STATUS);
|
||||||
if (Item && szStatusText && wcslen(szStatusText) > 0 && UrlHasBeenCopied == FALSE)
|
if (Item && szStatusText && wcslen(szStatusText) > 0 && UrlHasBeenCopied == FALSE)
|
||||||
{
|
{
|
||||||
|
@ -549,6 +554,7 @@ unsigned int WINAPI CDownloadManager::ThreadFunc(LPVOID param)
|
||||||
for (iAppId = 0; iAppId < InfoArray.GetSize(); ++iAppId)
|
for (iAppId = 0; iAppId < InfoArray.GetSize(); ++iAppId)
|
||||||
{
|
{
|
||||||
// Reset progress bar
|
// Reset progress bar
|
||||||
|
if (!IsWindow(hDlg)) break;
|
||||||
Item = GetDlgItem(hDlg, IDC_DOWNLOAD_PROGRESS);
|
Item = GetDlgItem(hDlg, IDC_DOWNLOAD_PROGRESS);
|
||||||
if (Item)
|
if (Item)
|
||||||
{
|
{
|
||||||
|
@ -580,6 +586,7 @@ unsigned int WINAPI CDownloadManager::ThreadFunc(LPVOID param)
|
||||||
szNewCaption.LoadStringW(IDS_DL_DIALOG_DB_DOWNLOAD_DISP);
|
szNewCaption.LoadStringW(IDS_DL_DIALOG_DB_DOWNLOAD_DISP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!IsWindow(hDlg)) goto end;
|
||||||
SetWindowTextW(hDlg, szNewCaption.GetString());
|
SetWindowTextW(hDlg, szNewCaption.GetString());
|
||||||
|
|
||||||
// build the path for the download
|
// build the path for the download
|
||||||
|
@ -617,6 +624,7 @@ unsigned int WINAPI CDownloadManager::ThreadFunc(LPVOID param)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the download URL
|
// Add the download URL
|
||||||
|
if (!IsWindow(hDlg)) goto end;
|
||||||
SetDlgItemTextW(hDlg, IDC_DOWNLOAD_STATUS, InfoArray[iAppId].szUrl.GetString());
|
SetDlgItemTextW(hDlg, IDC_DOWNLOAD_STATUS, InfoArray[iAppId].szUrl.GetString());
|
||||||
|
|
||||||
DownloadsListView.SetDownloadStatus(iAppId, DLSTATUS_DOWNLOADING);
|
DownloadsListView.SetDownloadStatus(iAppId, DLSTATUS_DOWNLOADING);
|
||||||
|
@ -770,6 +778,7 @@ unsigned int WINAPI CDownloadManager::ThreadFunc(LPVOID param)
|
||||||
}
|
}
|
||||||
|
|
||||||
dwCurrentBytesRead += dwBytesRead;
|
dwCurrentBytesRead += dwBytesRead;
|
||||||
|
if (!IsWindow(hDlg)) goto end;
|
||||||
UpdateProgress(hDlg, dwCurrentBytesRead, dwContentLen, 0, InfoArray[iAppId].szUrl.GetString());
|
UpdateProgress(hDlg, dwCurrentBytesRead, dwContentLen, 0, InfoArray[iAppId].szUrl.GetString());
|
||||||
} while (dwBytesRead && !bCancelled);
|
} while (dwBytesRead && !bCancelled);
|
||||||
|
|
||||||
|
@ -785,6 +794,7 @@ unsigned int WINAPI CDownloadManager::ThreadFunc(LPVOID param)
|
||||||
ProgressBar.SetMarquee(FALSE);
|
ProgressBar.SetMarquee(FALSE);
|
||||||
|
|
||||||
dwContentLen = dwCurrentBytesRead;
|
dwContentLen = dwCurrentBytesRead;
|
||||||
|
if (!IsWindow(hDlg)) goto end;
|
||||||
UpdateProgress(hDlg, dwCurrentBytesRead, dwContentLen, 0, InfoArray[iAppId].szUrl.GetString());
|
UpdateProgress(hDlg, dwCurrentBytesRead, dwContentLen, 0, InfoArray[iAppId].szUrl.GetString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -798,6 +808,7 @@ unsigned int WINAPI CDownloadManager::ThreadFunc(LPVOID param)
|
||||||
if (!szMsgText.LoadStringW(IDS_INTEG_CHECK_TITLE))
|
if (!szMsgText.LoadStringW(IDS_INTEG_CHECK_TITLE))
|
||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
|
if (!IsWindow(hDlg)) goto end;
|
||||||
SetWindowTextW(hDlg, szMsgText.GetString());
|
SetWindowTextW(hDlg, szMsgText.GetString());
|
||||||
SendMessageW(GetDlgItem(hDlg, IDC_DOWNLOAD_STATUS), WM_SETTEXT, 0, (LPARAM) Path.GetString());
|
SendMessageW(GetDlgItem(hDlg, IDC_DOWNLOAD_STATUS), WM_SETTEXT, 0, (LPARAM) Path.GetString());
|
||||||
|
|
||||||
|
@ -807,6 +818,7 @@ unsigned int WINAPI CDownloadManager::ThreadFunc(LPVOID param)
|
||||||
if (!szMsgText.LoadStringW(IDS_INTEG_CHECK_FAIL))
|
if (!szMsgText.LoadStringW(IDS_INTEG_CHECK_FAIL))
|
||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
|
if (!IsWindow(hDlg)) goto end;
|
||||||
MessageBoxW(hDlg, szMsgText.GetString(), NULL, MB_OK | MB_ICONERROR);
|
MessageBoxW(hDlg, szMsgText.GetString(), NULL, MB_OK | MB_ICONERROR);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
@ -831,6 +843,7 @@ run:
|
||||||
//reflect installation progress in the titlebar
|
//reflect installation progress in the titlebar
|
||||||
//TODO: make a separate string with a placeholder to include app name?
|
//TODO: make a separate string with a placeholder to include app name?
|
||||||
ATL::CStringW szMsgText = LoadStatusString(DLSTATUS_INSTALLING);
|
ATL::CStringW szMsgText = LoadStatusString(DLSTATUS_INSTALLING);
|
||||||
|
if (!IsWindow(hDlg)) goto end;
|
||||||
SetWindowTextW(hDlg, szMsgText.GetString());
|
SetWindowTextW(hDlg, szMsgText.GetString());
|
||||||
|
|
||||||
DownloadsListView.SetDownloadStatus(iAppId, DLSTATUS_INSTALLING);
|
DownloadsListView.SetDownloadStatus(iAppId, DLSTATUS_INSTALLING);
|
||||||
|
@ -858,10 +871,12 @@ end:
|
||||||
DeleteFileW(Path.GetString());
|
DeleteFileW(Path.GetString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!IsWindow(hDlg)) return 0;
|
||||||
DownloadsListView.SetDownloadStatus(iAppId, DLSTATUS_FINISHED);
|
DownloadsListView.SetDownloadStatus(iAppId, DLSTATUS_FINISHED);
|
||||||
}
|
}
|
||||||
|
|
||||||
delete static_cast<DownloadParam*>(param);
|
delete static_cast<DownloadParam*>(param);
|
||||||
|
if (!IsWindow(hDlg)) return 0;
|
||||||
SendMessageW(hDlg, WM_CLOSE, 0, 0);
|
SendMessageW(hDlg, WM_CLOSE, 0, 0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue