Mikhail Denisenko <denisenkom@gmail.com>

- RegisterDragDrop should be coupled with a RevokeDragDrop, so add that.
- Remove _pDropTarget from class members, it's a var local to DesktopShellView::InitDragDrop() method.
See issue #2012 for more details.

svn path=/trunk/; revision=41145
This commit is contained in:
Aleksey Bragin 2009-05-27 17:35:02 +00:00
parent b943ea64cf
commit bc373b83fc
2 changed files with 16 additions and 10 deletions

View file

@ -506,24 +506,29 @@ DesktopShellView::DesktopShellView(HWND hwnd, IShellView* pShellView)
InitDragDrop();
}
DesktopShellView::~DesktopShellView()
{
if (FAILED(RevokeDragDrop(_hwnd)))
assert(0);
}
bool DesktopShellView::InitDragDrop()
{
CONTEXT("DesktopShellView::InitDragDrop()");
_pDropTarget = new DesktopDropTarget(_hwnd);
DesktopDropTarget * pDropTarget = new DesktopDropTarget(_hwnd);
if (!_pDropTarget)
if (!pDropTarget)
return false;
_pDropTarget->AddRef();
pDropTarget->AddRef();
if (FAILED(RegisterDragDrop(_hwnd, _pDropTarget))) {
_pDropTarget->Release();
_pDropTarget = NULL;
if (FAILED(RegisterDragDrop(_hwnd, pDropTarget))) {
pDropTarget->Release();
return false;
}
else
_pDropTarget->Release();
FORMATETC ftetc;
@ -532,7 +537,8 @@ bool DesktopShellView::InitDragDrop()
ftetc.tymed = TYMED_HGLOBAL;
ftetc.cfFormat = CF_HDROP;
_pDropTarget->AddSuportedFormat(ftetc);
pDropTarget->AddSuportedFormat(ftetc);
pDropTarget->Release();
return true;
}

View file

@ -170,6 +170,7 @@ struct DesktopShellView : public ExtContextMenuHandlerT<SubclassedWindow>
typedef ExtContextMenuHandlerT<SubclassedWindow> super;
DesktopShellView(HWND hwnd, IShellView* pShellView);
~DesktopShellView();
bool InitDragDrop();
@ -186,7 +187,6 @@ protected:
void refresh();
DesktopDropTarget* _pDropTarget;
HWND _hwndListView;
int _icon_algo;
};