From 94406ba5bcf370d28988cfcb0830326e15723fbb Mon Sep 17 00:00:00 2001 From: Alexander Shaposhnikov Date: Thu, 24 Aug 2017 23:48:10 +0000 Subject: [PATCH] [RAPPS] - HACKFIX for ReactOS in gui.cpp - prevent counting below zero see explanation comment - Fix for percentage being shown incorrectly svn path=/branches/GSoC_2017/rapps/; revision=75664 --- reactos/base/applications/rapps/gui.cpp | 14 ++++++++++++-- reactos/base/applications/rapps/loaddlg.cpp | 10 +++++----- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/reactos/base/applications/rapps/gui.cpp b/reactos/base/applications/rapps/gui.cpp index d0a83461eea..fd824c7221a 100644 --- a/reactos/base/applications/rapps/gui.cpp +++ b/reactos/base/applications/rapps/gui.cpp @@ -1059,7 +1059,17 @@ private: if ((pnic->uNewState & LVIS_STATEIMAGEMASK) && !bUpdating) { BOOL checked = ListView_GetCheckState(pnic->hdr.hwndFrom, pnic->iItem); - nSelectedApps += (checked) ? 1 : -1; + /* FIXME: HAX! + - preventing decremention below zero as a safeguard for ReactOS + In ReactOS this action is triggered whenever user changes *selection*, but should be only when *checkbox* state toggled + Maybe LVIS_STATEIMAGEMASK is set incorrectly + */ + nSelectedApps += + (checked) + ? 1 + :((nSelectedApps > 0) + ? -1 + : 0); UpdateStatusBarText(); } } @@ -1290,7 +1300,7 @@ private: break; case ID_INSTALL: - if (nSelectedApps) + if (nSelectedApps > 0) { CDownloadManager::DownloadListOfApplications(m_ListView->GetCheckedItems()); UpdateApplicationsList(-1); diff --git a/reactos/base/applications/rapps/loaddlg.cpp b/reactos/base/applications/rapps/loaddlg.cpp index d024d860541..69ee830b804 100644 --- a/reactos/base/applications/rapps/loaddlg.cpp +++ b/reactos/base/applications/rapps/loaddlg.cpp @@ -163,9 +163,9 @@ public: m_UrlHasBeenCopied = TRUE; } - SetLastError(0); + SetLastError(ERROR_SUCCESS); r = GetWindowLongPtrW(m_hDialog, GWLP_USERDATA); - if (0 != r || 0 != GetLastError()) + if (r || GetLastError() != ERROR_SUCCESS) { *m_pbCancelled = TRUE; return E_ABORT; @@ -432,7 +432,7 @@ INT_PTR CALLBACK CDownloadManager::DownloadDlgProc(HWND Dlg, UINT uMsg, WPARAM w case WM_CLOSE: EndDialog(Dlg, 0); - DestroyWindow(Dlg); + //DestroyWindow(Dlg); return TRUE; default: @@ -719,6 +719,7 @@ DWORD WINAPI CDownloadManager::ThreadFunc(LPVOID param) if (hOut == INVALID_HANDLE_VALUE) goto end; + dwCurrentBytesRead = 0; do { if (!InternetReadFile(hFile, lpBuffer, _countof(lpBuffer), &dwBytesRead)) @@ -734,7 +735,7 @@ DWORD WINAPI CDownloadManager::ThreadFunc(LPVOID param) } dwCurrentBytesRead += dwBytesRead; - dl->OnProgress(dwCurrentBytesRead, dwContentLen, 0, pCurrentInfo->szUrlDownload); + dl->OnProgress(dwCurrentBytesRead, dwContentLen, 0, pCurrentInfo->szUrlDownload.GetString()); } while (dwBytesRead && !bCancelled); CloseHandle(hOut); @@ -870,6 +871,5 @@ VOID CDownloadManager::LaunchDownloadDialog(BOOL modal) hMainWnd, DownloadDlgProc); } - } // CDownloadManager