Author: tfaber
Date: Sun Jan  6 10:12:39 2013
New Revision: 58123

URL: http://svn.reactos.org/svn/reactos?rev=58123&view=rev
Log:
[EXPLORER_NEW]
- Plug a memory leak in IDropTargetImpl
- Do not allocate 64x the required space in TaskSwitchWnd_AllocTaskItem
- Properly free and unregister the tray window
- Fix a few more style issues

Modified:
    trunk/reactos/base/shell/explorer-new/dragdrop.c
    trunk/reactos/base/shell/explorer-new/explorer.c
    trunk/reactos/base/shell/explorer-new/startmnu.c
    trunk/reactos/base/shell/explorer-new/taskband.c
    trunk/reactos/base/shell/explorer-new/taskswnd.c
    trunk/reactos/base/shell/explorer-new/trayntfy.c
    trunk/reactos/base/shell/explorer-new/trayprop.c
    trunk/reactos/base/shell/explorer-new/traywnd.c

Modified: trunk/reactos/base/shell/explorer-new/dragdrop.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/explorer-new/dragdrop.c?rev=58123&r1=58122&r2=58123&view=diff
==============================================================================
--- trunk/reactos/base/shell/explorer-new/dragdrop.c [iso-8859-1] (original)
+++ trunk/reactos/base/shell/explorer-new/dragdrop.c [iso-8859-1] Sun Jan  6 
10:12:39 2013
@@ -62,6 +62,9 @@
 IDropTargetImpl_Free(IDropTargetImpl *This)
 {
     IDropTargetHelper_Release(This->DropTargetHelper);
+    HeapFree(hProcessHeap,
+             0,
+             This);
 }
 
 static ULONG STDMETHODCALLTYPE
@@ -127,10 +130,10 @@
     IDropTargetImpl *This;
     HRESULT hr;
 
-    This = (IDropTargetImpl *)HeapAlloc(hProcessHeap,
-                                        0,
-                                        FIELD_OFFSET(IDropTargetImpl,
-                                                     
Formats[nSupportedFormats]));
+    This = HeapAlloc(hProcessHeap,
+                     0,
+                     FIELD_OFFSET(IDropTargetImpl,
+                                  Formats[nSupportedFormats]));
     if (This != NULL)
     {
         ZeroMemory(This,
@@ -159,7 +162,7 @@
                               NULL,
                               CLSCTX_INPROC_SERVER,
                               &IID_IDropTargetHelper,
-                              (PVOID)&This->DropTargetHelper);
+                              (PVOID *)&This->DropTargetHelper);
 
         if (!SUCCEEDED(hr))
         {

Modified: trunk/reactos/base/shell/explorer-new/explorer.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/explorer-new/explorer.c?rev=58123&r1=58122&r2=58123&view=diff
==============================================================================
--- trunk/reactos/base/shell/explorer-new/explorer.c [iso-8859-1] (original)
+++ trunk/reactos/base/shell/explorer-new/explorer.c [iso-8859-1] Sun Jan  6 
10:12:39 2013
@@ -311,7 +311,7 @@
                     (LPVOID *)&lpTranslate,
                     &cbTranslate);
 
-                for (i = 0;i < (cbTranslate / sizeof(LANGCODEPAGE));i++)
+                for (i = 0; i < cbTranslate / sizeof(LANGCODEPAGE); i++)
                 {
                     /* If the bottom eight bits of the language id's
                     match, use this version information (since this
@@ -410,7 +410,11 @@
     }
 
     if (Tray != NULL)
+    {
         TrayMessageLoop(Tray);
+        ITrayWindow_Release(Tray);
+        UnregisterTrayWindowClass();
+    }
 
     if (hShellDesktop != NULL)
         DesktopDestroyShellWindow(hShellDesktop);

Modified: trunk/reactos/base/shell/explorer-new/startmnu.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/explorer-new/startmnu.c?rev=58123&r1=58122&r2=58123&view=diff
==============================================================================
--- trunk/reactos/base/shell/explorer-new/startmnu.c [iso-8859-1] (original)
+++ trunk/reactos/base/shell/explorer-new/startmnu.c [iso-8859-1] Sun Jan  6 
10:12:39 2013
@@ -59,10 +59,10 @@
     hRet = IShellFolder_GetUIObjectOf(psf,
                                       hWndOwner,
                                       1,
-                                      (LPCITEMIDLIST*)&pidl, /* FIXME: 
shouldn't need a typecast! */
+                                      (LPCITEMIDLIST *)&pidl,
                                       &IID_IContextMenu,
                                       NULL,
-                                      (PVOID*)&pcm);
+                                      (PVOID *)&pcm);
     if (SUCCEEDED(hRet))
     {
         hPopup = CreatePopupMenu();
@@ -82,9 +82,10 @@
                 return hPopup;
             }
 
-            IContextMenu_Release(pcm);
             DestroyMenu(hPopup);
         }
+
+        IContextMenu_Release(pcm);
     }
 
     return NULL;
@@ -96,7 +97,7 @@
                           IN PVOID pcmContext  OPTIONAL,
                           IN PVOID Context  OPTIONAL)
 {
-    PSTARTMNU_CTMENU_CTX psmcmc = (PSTARTMNU_CTMENU_CTX)pcmContext;
+    PSTARTMNU_CTMENU_CTX psmcmc = pcmContext;
 
     if (uiCmdId != 0)
     {
@@ -231,7 +232,7 @@
                 hRet = IShellFolder_BindToObject(psfDesktop,
                                                  pidlStart,
                                                  NULL,
-                                                 (REFIID)&IID_IShellFolder, /* 
FIXME: Shouldn't require a typecast */
+                                                 &IID_IShellFolder,
                                                  (PVOID*)&psfStart);
                 if (SUCCEEDED(hRet))
                 {
@@ -255,7 +256,7 @@
                             AddStartContextMenuItems(hWndOwner,
                                                      hPopup);
 
-                            *((PSTARTMNU_CTMENU_CTX*)ppcmContext) = psmcmc;
+                            *ppcmContext = psmcmc;
                             return hPopup;
                         }
                         else
@@ -815,11 +816,10 @@
 
     hRet = IMenuPopup_QueryInterface(pMenuPopup,
                                      &IID_IBanneredBar,
-                                     (PVOID)&pbb);
+                                     (PVOID *)&pbb);
     if (SUCCEEDED(hRet))
     {
         hRet = IBanneredBar_SetBitmap(pbb, hbmBanner);
-
 
         /* Update the icon size */
         hRet = IBanneredBar_SetIconSize(pbb,
@@ -831,7 +831,7 @@
     return hRet;
 }
 
-IMenuPopup*
+IMenuPopup *
 CreateStartMenu(IN ITrayWindow *Tray,
                 OUT IMenuBand **ppMenuBand,
                 IN HBITMAP hbmBanner  OPTIONAL,
@@ -855,7 +855,7 @@
                           NULL,
                           CLSCTX_INPROC_SERVER,
                           &IID_IMenuPopup,
-                          (PVOID*)&pMp);
+                          (PVOID *)&pMp);
     if (FAILED(hr))
     {
         DbgPrint("CoCreateInstance failed: %x\n", hr);
@@ -864,7 +864,7 @@
 
     hr = IMenuPopup_QueryInterface(pMp,
                                    &IID_IObjectWithSite,
-                                   (PVOID*)&pOws);
+                                   (PVOID *)&pOws);
     if (FAILED(hr))
     {
         DbgPrint("IMenuPopup_QueryInterface failed: %x\n", hr);
@@ -872,7 +872,7 @@
     }
 
     /* Set the menu site so we can handle messages */
-    hr = IObjectWithSite_SetSite(pOws, (IUnknown*)pSms);
+    hr = IObjectWithSite_SetSite(pOws, (IUnknown *)pSms);
     if (FAILED(hr))
     {
         DbgPrint("IObjectWithSite_SetSite failed: %x\n", hr);
@@ -903,7 +903,7 @@
         goto cleanup;
     }
 
-    hr = IUnknown_QueryInterface(pUnk, &IID_IBandSite, (PVOID*)&pBs);
+    hr = IUnknown_QueryInterface(pUnk, &IID_IBandSite, (PVOID *)&pBs);
     if (FAILED(hr))
     {
         DbgPrint("IUnknown_QueryInterface pBs failed: %x\n", hr);
@@ -919,7 +919,7 @@
         goto cleanup;
     }
 
-    hr = IBandSite_GetBandObject(pBs, dwBandId, &IID_IMenuBand, (PVOID*)&pMb);
+    hr = IBandSite_GetBandObject(pBs, dwBandId, &IID_IMenuBand, (PVOID *)&pMb);
     if (FAILED(hr))
     {
         DbgPrint("IBandSite_GetBandObject failed: %x\n", hr);

Modified: trunk/reactos/base/shell/explorer-new/taskband.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/explorer-new/taskband.c?rev=58123&r1=58122&r2=58123&view=diff
==============================================================================
--- trunk/reactos/base/shell/explorer-new/taskband.c [iso-8859-1] (original)
+++ trunk/reactos/base/shell/explorer-new/taskband.c [iso-8859-1] Sun Jan  6 
10:12:39 2013
@@ -506,7 +506,7 @@
         /* Check if the site supports IOleWindow */
         hRet = IUnknown_QueryInterface(pUnkSite,
                                        &IID_IOleWindow,
-                                       (PVOID*)&OleWindow);
+                                       (PVOID *)&OleWindow);
         if (SUCCEEDED(hRet))
         {
             HWND hWndParent = NULL;

Modified: trunk/reactos/base/shell/explorer-new/taskswnd.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/explorer-new/taskswnd.c?rev=58123&r1=58122&r2=58123&view=diff
==============================================================================
--- trunk/reactos/base/shell/explorer-new/taskswnd.c [iso-8859-1] (original)
+++ trunk/reactos/base/shell/explorer-new/taskswnd.c [iso-8859-1] Sun Jan  6 
10:12:39 2013
@@ -852,7 +852,19 @@
 
     ASSERT(This->AllocatedTaskItems >= This->TaskItemCount);
 
-    if (This->TaskItemCount != 0)
+    if (This->TaskItemCount == 0)
+    {
+        This->TaskItems = HeapAlloc(hProcessHeap,
+                                    0,
+                                    TASK_ITEM_ARRAY_ALLOC * 
sizeof(*This->TaskItems));
+        if (This->TaskItems != NULL)
+        {
+            This->AllocatedTaskItems = TASK_ITEM_ARRAY_ALLOC;
+        }
+        else
+            return NULL;
+    }
+    else if (This->TaskItemCount >= This->AllocatedTaskItems)
     {
         PTASK_ITEM NewArray;
         SIZE_T NewArrayLength, ActiveTaskItemIndex;
@@ -873,18 +885,6 @@
             }
             This->AllocatedTaskItems = (WORD)NewArrayLength;
             This->TaskItems = NewArray;
-        }
-        else
-            return NULL;
-    }
-    else
-    {
-        This->TaskItems = HeapAlloc(hProcessHeap,
-                                    0,
-                                    TASK_ITEM_ARRAY_ALLOC * 
sizeof(*This->TaskItems));
-        if (This->TaskItems != NULL)
-        {
-            This->AllocatedTaskItems = TASK_ITEM_ARRAY_ALLOC;
         }
         else
             return NULL;
@@ -2073,9 +2073,9 @@
             case WM_NCCREATE:
             {
                 LPCREATESTRUCT CreateStruct = (LPCREATESTRUCT)lParam;
-                This = (PTASK_SWITCH_WND)HeapAlloc(hProcessHeap,
-                                                   0,
-                                                   sizeof(*This));
+                This = HeapAlloc(hProcessHeap,
+                                 0,
+                                 sizeof(*This));
                 if (This == NULL)
                     return FALSE;
 

Modified: trunk/reactos/base/shell/explorer-new/trayntfy.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/explorer-new/trayntfy.c?rev=58123&r1=58122&r2=58123&view=diff
==============================================================================
--- trunk/reactos/base/shell/explorer-new/trayntfy.c [iso-8859-1] (original)
+++ trunk/reactos/base/shell/explorer-new/trayntfy.c [iso-8859-1] Sun Jan  6 
10:12:39 2013
@@ -239,7 +239,6 @@
         PNOTIFY_ITEM updateItem;
         deleteItem = *NotifyPointer;
 
-
         SendMessage(This->hWndToolbar,
                     TB_DELETEBUTTON,
                     deleteItem->Index,
@@ -611,16 +610,16 @@
 CreateSysPagerWnd(IN HWND hWndParent,
                   IN BOOL bVisible)
 {
-    PSYS_PAGER_WND_DATA TcData;
+    PSYS_PAGER_WND_DATA SpData;
     DWORD dwStyle;
     HWND hWnd = NULL;
 
-    TcData = HeapAlloc(hProcessHeap,
+    SpData = HeapAlloc(hProcessHeap,
                        0,
-                       sizeof(*TcData));
-    if (TcData != NULL)
-    {
-        ZeroMemory(TcData, sizeof(*TcData));
+                       sizeof(*SpData));
+    if (SpData != NULL)
+    {
+        ZeroMemory(SpData, sizeof(*SpData));
 
         /* Create the window. The tray window is going to move it to the 
correct
            position and resize it as needed. */
@@ -639,17 +638,19 @@
                               hWndParent,
                               NULL,
                               hExplorerInstance,
-                              TcData);
-
-        if (hWnd == NULL)
+                              SpData);
+
+        if (hWnd != NULL)
+        {
+            SetWindowTheme(hWnd, L"TrayNotify", NULL);
+        }
+        else
         {
             HeapFree(hProcessHeap,
                      0,
-                     TcData);
-        }
-    }
-
-    SetWindowTheme(hWnd, L"TrayNotify", NULL);
+                     SpData);
+        }
+    }
 
     return hWnd;
 
@@ -1381,16 +1382,19 @@
                               hWndParent,
                               NULL,
                               hExplorerInstance,
-                              (LPVOID)TcData);
-
-        if (hWnd == NULL)
+                              TcData);
+
+        if (hWnd != NULL)
+        {
+            SetWindowTheme(hWnd, L"TrayNotify", NULL);
+        }
+        else
         {
             HeapFree(hProcessHeap,
                      0,
                      TcData);
         }
     }
-    SetWindowTheme(hWnd, L"TrayNotify", NULL);
 
     return hWnd;
 
@@ -1860,7 +1864,7 @@
                               hWndTrayWindow,
                               NULL,
                               hExplorerInstance,
-                              (LPVOID)TnData);
+                              TnData);
 
         if (hWnd == NULL)
         {

Modified: trunk/reactos/base/shell/explorer-new/trayprop.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/explorer-new/trayprop.c?rev=58123&r1=58122&r2=58123&view=diff
==============================================================================
--- trunk/reactos/base/shell/explorer-new/trayprop.c [iso-8859-1] (original)
+++ trunk/reactos/base/shell/explorer-new/trayprop.c [iso-8859-1] Sun Jan  6 
10:12:39 2013
@@ -369,9 +369,9 @@
     PROPSHEETPAGE psp[5];
     TCHAR szCaption[256];
 
-    pPropInfo = (PPROPSHEET_INFO)HeapAlloc(hProcessHeap,
-                                           HEAP_ZERO_MEMORY,
-                                           sizeof(PROPSHEET_INFO));
+    pPropInfo = HeapAlloc(hProcessHeap,
+                          HEAP_ZERO_MEMORY,
+                          sizeof(PROPSHEET_INFO));
     if (!pPropInfo)
     {
         return NULL;

Modified: trunk/reactos/base/shell/explorer-new/traywnd.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/explorer-new/traywnd.c?rev=58123&r1=58122&r2=58123&view=diff
==============================================================================
--- trunk/reactos/base/shell/explorer-new/traywnd.c [iso-8859-1] (original)
+++ trunk/reactos/base/shell/explorer-new/traywnd.c [iso-8859-1] Sun Jan  6 
10:12:39 2013
@@ -2769,23 +2769,20 @@
 
     while (1)
     {
-        Ret = (GetMessage(&Msg,
-                          NULL,
-                          0,
-                          0) != 0);
-
-        if (Ret != -1)
-        {
-            if (!Ret)
-                break;
-
-            if (This->StartMenuBand == NULL ||
-                IMenuBand_IsMenuMessage(This->StartMenuBand,
-                                        &Msg) != S_OK)
-            {
-                TranslateMessage(&Msg);
-                DispatchMessage(&Msg);
-            }
+        Ret = GetMessage(&Msg,
+                         NULL,
+                         0,
+                         0);
+
+        if (!Ret || Ret == -1)
+            break;
+
+        if (This->StartMenuBand == NULL ||
+            IMenuBand_IsMenuMessage(This->StartMenuBand,
+                                    &Msg) != S_OK)
+        {
+            TranslateMessage(&Msg);
+            DispatchMessage(&Msg);
         }
     }
 }


Reply via email to