From bc373b83fc7f4fee404750a968fbdf6fde7511c7 Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Wed, 27 May 2009 17:35:02 +0000 Subject: [PATCH] Mikhail Denisenko - 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 --- .../base/shell/explorer/desktop/desktop.cpp | 24 ++++++++++++------- reactos/base/shell/explorer/desktop/desktop.h | 2 +- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/reactos/base/shell/explorer/desktop/desktop.cpp b/reactos/base/shell/explorer/desktop/desktop.cpp index 381162faabf..eef44aa3f14 100644 --- a/reactos/base/shell/explorer/desktop/desktop.cpp +++ b/reactos/base/shell/explorer/desktop/desktop.cpp @@ -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; } diff --git a/reactos/base/shell/explorer/desktop/desktop.h b/reactos/base/shell/explorer/desktop/desktop.h index da5876debe3..b3907a9fae1 100644 --- a/reactos/base/shell/explorer/desktop/desktop.h +++ b/reactos/base/shell/explorer/desktop/desktop.h @@ -170,6 +170,7 @@ struct DesktopShellView : public ExtContextMenuHandlerT typedef ExtContextMenuHandlerT super; DesktopShellView(HWND hwnd, IShellView* pShellView); + ~DesktopShellView(); bool InitDragDrop(); @@ -186,7 +187,6 @@ protected: void refresh(); - DesktopDropTarget* _pDropTarget; HWND _hwndListView; int _icon_algo; };