[RAPPS]
authorAlexander Shaposhnikov <sanchaez@reactos.org>
Thu, 24 Aug 2017 23:48:10 +0000 (23:48 +0000)
committerAlexander Shaposhnikov <sanchaez@reactos.org>
Thu, 24 Aug 2017 23:48:10 +0000 (23:48 +0000)
- 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
reactos/base/applications/rapps/loaddlg.cpp

index d0a8346..fd824c7 100644 (file)
@@ -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);
index d024d86..69ee830 100644 (file)
@@ -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