Author: akhaldi
Date: Sat Nov  5 11:07:31 2016
New Revision: 73131

URL: http://svn.reactos.org/svn/reactos?rev=73131&view=rev
Log:
[0.4.3] * Merge shell32 fixes by Giannis in r73128. CORE-12106

Modified:
    branches/ros-branch-0_4_3/   (props changed)
    branches/ros-branch-0_4_3/reactos/   (props changed)
    
branches/ros-branch-0_4_3/reactos/dll/win32/shell32/folders/CDrivesFolder.cpp
    branches/ros-branch-0_4_3/reactos/dll/win32/shell32/folders/CFSFolder.cpp
    branches/ros-branch-0_4_3/reactos/dll/win32/shell32/folders/CRegFolder.cpp
    branches/ros-branch-0_4_3/reactos/dll/win32/shell32/shfldr.h
    branches/ros-branch-0_4_3/reactos/dll/win32/shell32/shlfolder.cpp

Propchange: branches/ros-branch-0_4_3/
------------------------------------------------------------------------------
--- svn:mergeinfo       (original)
+++ svn:mergeinfo       Sat Nov  5 11:07:31 2016
@@ -1 +1 @@
-/trunk:73043,73072,73075,73077,73112-73114,73117
+/trunk:73043,73072,73075,73077,73112-73114,73117,73128

Propchange: branches/ros-branch-0_4_3/reactos/
------------------------------------------------------------------------------
--- svn:mergeinfo       (original)
+++ svn:mergeinfo       Sat Nov  5 11:07:31 2016
@@ -21,4 +21,4 @@
 
/branches/usb-bringup:51335,51337,51341-51343,51348,51350,51353,51355,51365-51369,51372,51384-54388,54396-54398,54736-54737,54752-54754,54756-54760,54762,54764-54765,54767-54768,54772,54774-54777,54781,54787,54790-54792,54797-54798,54806,54808,54834-54838,54843,54850,54852,54856,54858-54859
 /branches/usb-bringup-trunk:55019-55543,55548-55554,55556-55567
 /branches/wlan-bringup:54809-54998
-/trunk/reactos:73043,73072,73075,73077,73112-73114,73117
+/trunk/reactos:73043,73072,73075,73077,73112-73114,73117,73128

Modified: 
branches/ros-branch-0_4_3/reactos/dll/win32/shell32/folders/CDrivesFolder.cpp
URL: 
http://svn.reactos.org/svn/reactos/branches/ros-branch-0_4_3/reactos/dll/win32/shell32/folders/CDrivesFolder.cpp?rev=73131&r1=73130&r2=73131&view=diff
==============================================================================
--- 
branches/ros-branch-0_4_3/reactos/dll/win32/shell32/folders/CDrivesFolder.cpp   
    [iso-8859-1] (original)
+++ 
branches/ros-branch-0_4_3/reactos/dll/win32/shell32/folders/CDrivesFolder.cpp   
    [iso-8859-1] Sat Nov  5 11:07:31 2016
@@ -358,6 +358,8 @@
 
 HRESULT WINAPI CDrivesFolder::CompareIDs(LPARAM lParam, PCUIDLIST_RELATIVE 
pidl1, PCUIDLIST_RELATIVE pidl2)
 {
+    HRESULT hres;
+
     if (!pidl1 || !pidl2)
     {
         ERR("Got null pidl pointer (%Ix %p %p)!\n", lParam, pidl1, pidl2);
@@ -365,7 +367,7 @@
     }
 
     if (_ILIsSpecialFolder(pidl1) || _ILIsSpecialFolder(pidl2))
-        m_regFolder->CompareIDs(lParam, pidl1, pidl2);
+        return m_regFolder->CompareIDs(lParam, pidl1, pidl2);
 
     if (!_ILIsDrive(pidl1) || !_ILIsDrive(pidl2) || LOWORD(lParam) >= 
MYCOMPUTERSHELLVIEWCOLUMNS)
         return E_INVALIDARG;
@@ -379,10 +381,12 @@
         case 0:        /* name */
         {
             result = stricmp(pszDrive1, pszDrive2);
-            return MAKE_COMPARE_HRESULT(result);
+            hres = MAKE_COMPARE_HRESULT(result);
+            break;
         }
         case 1:        /* Type */
         {
+            /* We want to return immediately because SHELL32_CompareDetails 
also compares children. */
             return SHELL32_CompareDetails(this, lParam, pidl1, pidl2);
         }
         case 2:       /* Size */
@@ -406,10 +410,17 @@
             else /* Size available */
                 Diff.QuadPart = Drive1Available.QuadPart - 
Drive2Available.QuadPart;
 
-            return MAKE_COMPARE_HRESULT(Diff.QuadPart);
-        }
-    }
-    return E_INVALIDARG;
+            hres = MAKE_COMPARE_HRESULT(Diff.QuadPart);
+            break;
+        }
+        default:
+            return E_INVALIDARG;
+    }
+
+    if (HRESULT_CODE(hres) == 0)
+        return SHELL32_CompareChildren(this, lParam, pidl1, pidl2);
+
+    return hres;
 }
 
 /**************************************************************************

Modified: 
branches/ros-branch-0_4_3/reactos/dll/win32/shell32/folders/CFSFolder.cpp
URL: 
http://svn.reactos.org/svn/reactos/branches/ros-branch-0_4_3/reactos/dll/win32/shell32/folders/CFSFolder.cpp?rev=73131&r1=73130&r2=73131&view=diff
==============================================================================
--- branches/ros-branch-0_4_3/reactos/dll/win32/shell32/folders/CFSFolder.cpp   
[iso-8859-1] (original)
+++ branches/ros-branch-0_4_3/reactos/dll/win32/shell32/folders/CFSFolder.cpp   
[iso-8859-1] Sat Nov  5 11:07:31 2016
@@ -344,6 +344,10 @@
         case 4: /* Attributes */
             return SHELL32_CompareDetails(this, lParam, pidl1, pidl2);
     }
+
+    if (result == 0)
+        return SHELL32_CompareChildren(this, lParam, pidl1, pidl2);
+
     return MAKE_COMPARE_HRESULT(result);
 }
 

Modified: 
branches/ros-branch-0_4_3/reactos/dll/win32/shell32/folders/CRegFolder.cpp
URL: 
http://svn.reactos.org/svn/reactos/branches/ros-branch-0_4_3/reactos/dll/win32/shell32/folders/CRegFolder.cpp?rev=73131&r1=73130&r2=73131&view=diff
==============================================================================
--- branches/ros-branch-0_4_3/reactos/dll/win32/shell32/folders/CRegFolder.cpp  
[iso-8859-1] (original)
+++ branches/ros-branch-0_4_3/reactos/dll/win32/shell32/folders/CRegFolder.cpp  
[iso-8859-1] Sat Nov  5 11:07:31 2016
@@ -282,21 +282,24 @@
         return E_INVALIDARG;
     }
 
-    BOOL bIsGuidFolder1 = _ILIsSpecialFolder(pidl1);
-    BOOL bIsGuidFolder2 = _ILIsSpecialFolder(pidl2);
-
-    if (!bIsGuidFolder1 && !bIsGuidFolder2)
+    GUID const *clsid1 = _ILGetGUIDPointer (pidl1);
+    GUID const *clsid2 = _ILGetGUIDPointer (pidl2);
+
+    if (!clsid1 && !clsid2)
     {
         ERR("Got no guid pidl!\n");
         return E_INVALIDARG;
     }
-    else if (bIsGuidFolder1 && bIsGuidFolder2)
-    {
+    else if (clsid1 && clsid2)
+    {
+        if (memcmp(clsid1, clsid2, sizeof(GUID)) == 0)
+            return SHELL32_CompareChildren(this, lParam, pidl1, pidl2);
+
         return SHELL32_CompareDetails(this, lParam, pidl1, pidl2);
     }
 
     /* Guid folders come first compared to everything else */
-    return MAKE_COMPARE_HRESULT(bIsGuidFolder1 ? -1 : 1);
+    return MAKE_COMPARE_HRESULT(clsid1 ? -1 : 1);
 }
 
 HRESULT WINAPI CRegFolder::CreateViewObject(HWND hwndOwner, REFIID riid, 
LPVOID *ppvOut)

Modified: branches/ros-branch-0_4_3/reactos/dll/win32/shell32/shfldr.h
URL: 
http://svn.reactos.org/svn/reactos/branches/ros-branch-0_4_3/reactos/dll/win32/shell32/shfldr.h?rev=73131&r1=73130&r2=73131&view=diff
==============================================================================
--- branches/ros-branch-0_4_3/reactos/dll/win32/shell32/shfldr.h        
[iso-8859-1] (original)
+++ branches/ros-branch-0_4_3/reactos/dll/win32/shell32/shfldr.h        
[iso-8859-1] Sat Nov  5 11:07:31 2016
@@ -53,6 +53,8 @@
 
 HRESULT SHELL32_CompareDetails(IShellFolder2* isf, LPARAM lParam, 
LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2);
 
+HRESULT SHELL32_CompareChildren(IShellFolder2* psf, LPARAM lParam, 
LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2);
+
 HRESULT SHELL32_CoCreateInitSF (LPCITEMIDLIST pidlRoot, LPCWSTR pathRoot,
                 LPCITEMIDLIST pidlChild, const GUID* clsid, int csidl, REFIID 
riid, LPVOID *ppvOut);
                 

Modified: branches/ros-branch-0_4_3/reactos/dll/win32/shell32/shlfolder.cpp
URL: 
http://svn.reactos.org/svn/reactos/branches/ros-branch-0_4_3/reactos/dll/win32/shell32/shlfolder.cpp?rev=73131&r1=73130&r2=73131&view=diff
==============================================================================
--- branches/ros-branch-0_4_3/reactos/dll/win32/shell32/shlfolder.cpp   
[iso-8859-1] (original)
+++ branches/ros-branch-0_4_3/reactos/dll/win32/shell32/shlfolder.cpp   
[iso-8859-1] Sat Nov  5 11:07:31 2016
@@ -435,6 +435,29 @@
     return S_OK;
 }
 
+HRESULT SHELL32_CompareChildren(IShellFolder2* psf, LPARAM lParam, 
LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
+{
+    PUIDLIST_RELATIVE nextpidl1 = ILGetNext (pidl1);
+    PUIDLIST_RELATIVE nextpidl2 = ILGetNext (pidl2);
+
+    bool isEmpty1 = _ILIsDesktop(nextpidl1);
+    bool isEmpty2 = _ILIsDesktop(nextpidl2);
+    if (isEmpty1 || isEmpty2)
+        return MAKE_COMPARE_HRESULT(isEmpty2 - isEmpty1);
+
+    PITEMID_CHILD firstpidl = ILCloneFirst (pidl1);
+    if (!firstpidl)
+        return E_OUTOFMEMORY;
+
+    CComPtr<IShellFolder> psf2;
+    HRESULT hr = psf->BindToObject(firstpidl, 0, IID_PPV_ARG(IShellFolder, 
&psf2));
+    ILFree(firstpidl);
+    if (FAILED(hr))
+        return MAKE_COMPARE_HRESULT(0);
+
+    return psf2->CompareIDs(lParam, nextpidl1, nextpidl2);
+}
+
 HRESULT SHELL32_CompareDetails(IShellFolder2* isf, LPARAM lParam, 
LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
 {
     SHELLDETAILS sd;
@@ -458,6 +481,8 @@
         return MAKE_COMPARE_HRESULT(1);
 
     int ret = wcsicmp(wszItem1, wszItem2);
+    if (ret == 0)
+        return SHELL32_CompareChildren(isf, lParam, pidl1, pidl2);
 
     return MAKE_COMPARE_HRESULT(ret);
 }


Reply via email to