mirror of
https://github.com/reactos/reactos.git
synced 2025-02-23 17:05:46 +00:00
[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 svn path=/trunk/; revision=58123
This commit is contained in:
parent
b9a482f6fd
commit
6effe35b24
8 changed files with 78 additions and 70 deletions
|
@ -62,6 +62,9 @@ static VOID
|
|||
IDropTargetImpl_Free(IDropTargetImpl *This)
|
||||
{
|
||||
IDropTargetHelper_Release(This->DropTargetHelper);
|
||||
HeapFree(hProcessHeap,
|
||||
0,
|
||||
This);
|
||||
}
|
||||
|
||||
static ULONG STDMETHODCALLTYPE
|
||||
|
@ -127,10 +130,10 @@ CreateDropTarget(IN HWND hwndTarget,
|
|||
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 @@ CreateDropTarget(IN HWND hwndTarget,
|
|||
NULL,
|
||||
CLSCTX_INPROC_SERVER,
|
||||
&IID_IDropTargetHelper,
|
||||
(PVOID)&This->DropTargetHelper);
|
||||
(PVOID *)&This->DropTargetHelper);
|
||||
|
||||
if (!SUCCEEDED(hr))
|
||||
{
|
||||
|
|
|
@ -311,7 +311,7 @@ GetVersionInfoString(IN TCHAR *szFileName,
|
|||
(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 @@ _tWinMain(IN HINSTANCE hInstance,
|
|||
}
|
||||
|
||||
if (Tray != NULL)
|
||||
{
|
||||
TrayMessageLoop(Tray);
|
||||
ITrayWindow_Release(Tray);
|
||||
UnregisterTrayWindowClass();
|
||||
}
|
||||
|
||||
if (hShellDesktop != NULL)
|
||||
DesktopDestroyShellWindow(hShellDesktop);
|
||||
|
|
|
@ -59,10 +59,10 @@ CreateContextMenuFromShellFolderPidl(IN HWND hWndOwner,
|
|||
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 @@ CreateContextMenuFromShellFolderPidl(IN HWND hWndOwner,
|
|||
return hPopup;
|
||||
}
|
||||
|
||||
IContextMenu_Release(pcm);
|
||||
DestroyMenu(hPopup);
|
||||
}
|
||||
|
||||
IContextMenu_Release(pcm);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
@ -96,7 +97,7 @@ OnStartContextMenuCommand(IN HWND hWndOwner,
|
|||
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 @@ CreateStartContextMenu(IN HWND hWndOwner,
|
|||
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 @@ CreateStartContextMenu(IN HWND hWndOwner,
|
|||
AddStartContextMenuItems(hWndOwner,
|
||||
hPopup);
|
||||
|
||||
*((PSTARTMNU_CTMENU_CTX*)ppcmContext) = psmcmc;
|
||||
*ppcmContext = psmcmc;
|
||||
return hPopup;
|
||||
}
|
||||
else
|
||||
|
@ -815,12 +816,11 @@ UpdateStartMenu(IN OUT IMenuPopup *pMenuPopup,
|
|||
|
||||
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,
|
||||
bSmallIcons ? BMICON_SMALL : BMICON_LARGE);
|
||||
|
@ -831,7 +831,7 @@ UpdateStartMenu(IN OUT IMenuPopup *pMenuPopup,
|
|||
return hRet;
|
||||
}
|
||||
|
||||
IMenuPopup*
|
||||
IMenuPopup *
|
||||
CreateStartMenu(IN ITrayWindow *Tray,
|
||||
OUT IMenuBand **ppMenuBand,
|
||||
IN HBITMAP hbmBanner OPTIONAL,
|
||||
|
@ -855,7 +855,7 @@ CreateStartMenu(IN ITrayWindow *Tray,
|
|||
NULL,
|
||||
CLSCTX_INPROC_SERVER,
|
||||
&IID_IMenuPopup,
|
||||
(PVOID*)&pMp);
|
||||
(PVOID *)&pMp);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
DbgPrint("CoCreateInstance failed: %x\n", hr);
|
||||
|
@ -864,7 +864,7 @@ CreateStartMenu(IN ITrayWindow *Tray,
|
|||
|
||||
hr = IMenuPopup_QueryInterface(pMp,
|
||||
&IID_IObjectWithSite,
|
||||
(PVOID*)&pOws);
|
||||
(PVOID *)&pOws);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
DbgPrint("IMenuPopup_QueryInterface failed: %x\n", hr);
|
||||
|
@ -872,7 +872,7 @@ CreateStartMenu(IN ITrayWindow *Tray,
|
|||
}
|
||||
|
||||
/* 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 @@ CreateStartMenu(IN ITrayWindow *Tray,
|
|||
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 @@ CreateStartMenu(IN ITrayWindow *Tray,
|
|||
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);
|
||||
|
|
|
@ -506,7 +506,7 @@ ITaskBandImpl_SetSite(IN OUT IObjectWithSite *iface,
|
|||
/* Check if the site supports IOleWindow */
|
||||
hRet = IUnknown_QueryInterface(pUnkSite,
|
||||
&IID_IOleWindow,
|
||||
(PVOID*)&OleWindow);
|
||||
(PVOID *)&OleWindow);
|
||||
if (SUCCEEDED(hRet))
|
||||
{
|
||||
HWND hWndParent = NULL;
|
||||
|
|
|
@ -852,7 +852,19 @@ TaskSwitchWnd_AllocTaskItem(IN OUT PTASK_SWITCH_WND This)
|
|||
|
||||
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;
|
||||
|
@ -877,18 +889,6 @@ TaskSwitchWnd_AllocTaskItem(IN OUT PTASK_SWITCH_WND This)
|
|||
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;
|
||||
}
|
||||
|
||||
return This->TaskItems + This->TaskItemCount++;
|
||||
}
|
||||
|
@ -2073,9 +2073,9 @@ ForwardContextMenuMsg:
|
|||
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;
|
||||
|
||||
|
|
|
@ -239,7 +239,6 @@ SysPagerWnd_RemoveButton(IN OUT PSYS_PAGER_WND_DATA This,
|
|||
PNOTIFY_ITEM updateItem;
|
||||
deleteItem = *NotifyPointer;
|
||||
|
||||
|
||||
SendMessage(This->hWndToolbar,
|
||||
TB_DELETEBUTTON,
|
||||
deleteItem->Index,
|
||||
|
@ -611,16 +610,16 @@ static HWND
|
|||
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)
|
||||
sizeof(*SpData));
|
||||
if (SpData != NULL)
|
||||
{
|
||||
ZeroMemory(TcData, sizeof(*TcData));
|
||||
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,18 +638,20 @@ CreateSysPagerWnd(IN HWND hWndParent,
|
|||
hWndParent,
|
||||
NULL,
|
||||
hExplorerInstance,
|
||||
TcData);
|
||||
SpData);
|
||||
|
||||
if (hWnd == NULL)
|
||||
if (hWnd != NULL)
|
||||
{
|
||||
SetWindowTheme(hWnd, L"TrayNotify", NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
HeapFree(hProcessHeap,
|
||||
0,
|
||||
TcData);
|
||||
SpData);
|
||||
}
|
||||
}
|
||||
|
||||
SetWindowTheme(hWnd, L"TrayNotify", NULL);
|
||||
|
||||
return hWnd;
|
||||
|
||||
}
|
||||
|
@ -1381,16 +1382,19 @@ CreateTrayClockWnd(IN HWND hWndParent,
|
|||
hWndParent,
|
||||
NULL,
|
||||
hExplorerInstance,
|
||||
(LPVOID)TcData);
|
||||
TcData);
|
||||
|
||||
if (hWnd == NULL)
|
||||
if (hWnd != NULL)
|
||||
{
|
||||
SetWindowTheme(hWnd, L"TrayNotify", NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
HeapFree(hProcessHeap,
|
||||
0,
|
||||
TcData);
|
||||
}
|
||||
}
|
||||
SetWindowTheme(hWnd, L"TrayNotify", NULL);
|
||||
|
||||
return hWnd;
|
||||
|
||||
|
@ -1860,7 +1864,7 @@ CreateTrayNotifyWnd(IN OUT ITrayWindow *TrayWindow,
|
|||
hWndTrayWindow,
|
||||
NULL,
|
||||
hExplorerInstance,
|
||||
(LPVOID)TnData);
|
||||
TnData);
|
||||
|
||||
if (hWnd == NULL)
|
||||
{
|
||||
|
|
|
@ -369,9 +369,9 @@ DisplayTrayProperties(ITrayWindow *Tray)
|
|||
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;
|
||||
|
|
|
@ -2769,23 +2769,20 @@ TrayMessageLoop(IN OUT ITrayWindow *Tray)
|
|||
|
||||
while (1)
|
||||
{
|
||||
Ret = (GetMessage(&Msg,
|
||||
NULL,
|
||||
0,
|
||||
0) != 0);
|
||||
Ret = GetMessage(&Msg,
|
||||
NULL,
|
||||
0,
|
||||
0);
|
||||
|
||||
if (Ret != -1)
|
||||
if (!Ret || Ret == -1)
|
||||
break;
|
||||
|
||||
if (This->StartMenuBand == NULL ||
|
||||
IMenuBand_IsMenuMessage(This->StartMenuBand,
|
||||
&Msg) != S_OK)
|
||||
{
|
||||
if (!Ret)
|
||||
break;
|
||||
|
||||
if (This->StartMenuBand == NULL ||
|
||||
IMenuBand_IsMenuMessage(This->StartMenuBand,
|
||||
&Msg) != S_OK)
|
||||
{
|
||||
TranslateMessage(&Msg);
|
||||
DispatchMessage(&Msg);
|
||||
}
|
||||
TranslateMessage(&Msg);
|
||||
DispatchMessage(&Msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue