Andrew Nguyen : shell32: Keep at least one reference to the autocompletion object at initialization until the edit window is destroyed .
Alexandre Julliard
julliard at winehq.org
Tue Feb 1 12:24:58 CST 2011
Module: wine
Branch: master
Commit: fff50be3e8018df5292de632c88771f7cf78563d
URL: http://source.winehq.org/git/wine.git/?a=commit;h=fff50be3e8018df5292de632c88771f7cf78563d
Author: Andrew Nguyen <anguyen at codeweavers.com>
Date: Tue Feb 1 04:16:38 2011 -0600
shell32: Keep at least one reference to the autocompletion object at initialization until the edit window is destroyed.
Spotted with Valgrind.
---
dlls/shell32/autocomplete.c | 19 ++++++++++++-------
1 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/dlls/shell32/autocomplete.c b/dlls/shell32/autocomplete.c
index b259f6f..8db542a 100644
--- a/dlls/shell32/autocomplete.c
+++ b/dlls/shell32/autocomplete.c
@@ -203,18 +203,16 @@ static ULONG WINAPI IAutoComplete2_fnRelease(
{
IAutoCompleteImpl *This = (IAutoCompleteImpl *)iface;
ULONG refCount = InterlockedDecrement(&This->ref);
-
+
TRACE("(%p)->(%u)\n", This, refCount + 1);
if (!refCount) {
- TRACE(" destroying IAutoComplete(%p)\n",This);
+ TRACE("destroying IAutoComplete(%p)\n", This);
HeapFree(GetProcessHeap(), 0, This->quickComplete);
HeapFree(GetProcessHeap(), 0, This->txtbackup);
- if (This->hwndListBox)
- DestroyWindow(This->hwndListBox);
- if (This->enumstr)
- IEnumString_Release(This->enumstr);
- HeapFree(GetProcessHeap(), 0, This);
+ if (This->enumstr)
+ IEnumString_Release(This->enumstr);
+ HeapFree(GetProcessHeap(), 0, This);
}
return refCount;
}
@@ -275,6 +273,8 @@ static HRESULT WINAPI IAutoComplete2_fnInit(
This->initialized = TRUE;
This->hwndEdit = hwndEdit;
This->wpOrigEditProc = (WNDPROC) SetWindowLongPtrW( hwndEdit, GWLP_WNDPROC, (LONG_PTR) ACEditSubclassProc);
+ /* Keep at least one reference to the object until the edit window is destroyed. */
+ IAutoComplete2_AddRef((IAutoComplete2 *)This);
SetPropW( hwndEdit, autocomplete_propertyW, This );
if (This->options & ACO_AUTOSUGGEST)
@@ -631,7 +631,12 @@ static LRESULT APIENTRY ACEditSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam,
{
WNDPROC proc = This->wpOrigEditProc;
+ RemovePropW(hwnd, autocomplete_propertyW);
+ SetWindowLongPtrW(hwnd, GWLP_WNDPROC, (LONG_PTR)proc);
This->hwndEdit = NULL;
+ if (This->hwndListBox)
+ DestroyWindow(This->hwndListBox);
+ IAutoComplete2_Release((IAutoComplete2 *)This);
return CallWindowProcW(proc, hwnd, uMsg, wParam, lParam);
}
default:
More information about the wine-cvs
mailing list