https://git.reactos.org/?p=reactos.git;a=commitdiff;h=c5e111427c7945c9f687f3...
commit c5e111427c7945c9f687f32d975c1eb694777cc1 Author: 赫杨 1160386205@qq.com AuthorDate: Sun Aug 16 03:38:28 2020 +0800 Commit: Mark Jansen mark.jansen@reactos.org CommitDate: Sun Sep 6 17:10:16 2020 +0200
[RAPPS] reduce the chance assert failed --- base/applications/rapps/loaddlg.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/base/applications/rapps/loaddlg.cpp b/base/applications/rapps/loaddlg.cpp index dce708347bf..505e48643d7 100644 --- a/base/applications/rapps/loaddlg.cpp +++ b/base/applications/rapps/loaddlg.cpp @@ -149,6 +149,7 @@ public: UINT uiPercentage = ((ULONGLONG) ulProgress * 100) / ulProgressMax;
/* send the current progress to the progress bar */ + if (!IsWindow()) return; SendMessage(PBM_SETPOS, uiPercentage, 0);
/* format total download size */ @@ -163,6 +164,7 @@ public: else { /* send the current progress to the progress bar */ + if (!IsWindow()) return; SendMessage(PBM_SETPOS, 0, 0);
/* total size is not known, display only current size */ @@ -170,6 +172,7 @@ public: }
/* and finally display it */ + if (!IsWindow()) return; SendMessage(WM_SETTEXT, 0, (LPARAM) ProgressText.GetString()); }
@@ -492,8 +495,10 @@ VOID CDownloadManager::UpdateProgress( { HWND Item;
+ if (!IsWindow(hDlg)) return; ProgressBar.SetProgress(ulProgress, ulProgressMax);
+ if (!IsWindow(hDlg)) return; Item = GetDlgItem(hDlg, IDC_DOWNLOAD_STATUS); if (Item && szStatusText && wcslen(szStatusText) > 0 && UrlHasBeenCopied == FALSE) { @@ -580,6 +585,7 @@ unsigned int WINAPI CDownloadManager::ThreadFunc(LPVOID param) for (iAppId = 0; iAppId < InfoArray.GetSize(); ++iAppId) { // Reset progress bar + if (!IsWindow(hDlg)) break; Item = GetDlgItem(hDlg, IDC_DOWNLOAD_PROGRESS); if (Item) { @@ -616,7 +622,7 @@ unsigned int WINAPI CDownloadManager::ThreadFunc(LPVOID param) break; }
- + if (!IsWindow(hDlg)) goto end; SetWindowTextW(hDlg, szNewCaption.GetString());
// build the path for the download @@ -671,6 +677,7 @@ unsigned int WINAPI CDownloadManager::ThreadFunc(LPVOID param) }
// Add the download URL + if (!IsWindow(hDlg)) goto end; SetDlgItemTextW(hDlg, IDC_DOWNLOAD_STATUS, InfoArray[iAppId].szUrl.GetString());
DownloadsListView.SetDownloadStatus(iAppId, DLSTATUS_DOWNLOADING); @@ -832,6 +839,7 @@ unsigned int WINAPI CDownloadManager::ThreadFunc(LPVOID param) }
dwCurrentBytesRead += dwBytesRead; + if (!IsWindow(hDlg)) goto end; UpdateProgress(hDlg, dwCurrentBytesRead, dwContentLen, 0, InfoArray[iAppId].szUrl.GetString()); } while (dwBytesRead && !bCancelled);
@@ -850,6 +858,7 @@ unsigned int WINAPI CDownloadManager::ThreadFunc(LPVOID param) ProgressBar.SetMarquee(FALSE);
dwContentLen = dwCurrentBytesRead; + if (!IsWindow(hDlg)) goto end; UpdateProgress(hDlg, dwCurrentBytesRead, dwContentLen, 0, InfoArray[iAppId].szUrl.GetString()); }
@@ -866,6 +875,7 @@ unsigned int WINAPI CDownloadManager::ThreadFunc(LPVOID param) goto end; }
+ if (!IsWindow(hDlg)) goto end; SetWindowTextW(hDlg, szMsgText.GetString()); SendMessageW(GetDlgItem(hDlg, IDC_DOWNLOAD_STATUS), WM_SETTEXT, 0, (LPARAM) Path.GetString());
@@ -878,6 +888,7 @@ unsigned int WINAPI CDownloadManager::ThreadFunc(LPVOID param) goto end; }
+ if (!IsWindow(hDlg)) goto end; MessageBoxW(hDlg, szMsgText.GetString(), NULL, MB_OK | MB_ICONERROR); goto end; } @@ -902,6 +913,7 @@ run: //reflect installation progress in the titlebar //TODO: make a separate string with a placeholder to include app name? ATL::CStringW szMsgText = LoadStatusString(DLSTATUS_INSTALLING); + if (!IsWindow(hDlg)) goto end; SetWindowTextW(hDlg, szMsgText.GetString());
DownloadsListView.SetDownloadStatus(iAppId, DLSTATUS_INSTALLING); @@ -929,10 +941,12 @@ end: DeleteFileW(Path.GetString()); }
+ if (!IsWindow(hDlg)) return 0; DownloadsListView.SetDownloadStatus(iAppId, DLSTATUS_FINISHED); }
delete static_cast<DownloadParam*>(param); + if (!IsWindow(hDlg)) return 0; SendMessageW(hDlg, WM_CLOSE, 0, 0); return 0; }