Author: fireball
Date: Wed May 27 21:35:02 2009
New Revision: 41145

URL: http://svn.reactos.org/svn/reactos?rev=41145&view=rev
Log:
Mikhail Denisenko <denisen...@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.

Modified:
    trunk/reactos/base/shell/explorer/desktop/desktop.cpp
    trunk/reactos/base/shell/explorer/desktop/desktop.h

Modified: trunk/reactos/base/shell/explorer/desktop/desktop.cpp
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/explorer/desktop/desktop.cpp?rev=41145&r1=41144&r2=41145&view=diff
==============================================================================
--- trunk/reactos/base/shell/explorer/desktop/desktop.cpp [iso-8859-1] 
(original)
+++ trunk/reactos/base/shell/explorer/desktop/desktop.cpp [iso-8859-1] Wed May 
27 21:35:02 2009
@@ -506,24 +506,29 @@
        InitDragDrop();
 }
 
+
+DesktopShellView::~DesktopShellView()
+{
+       if (FAILED(RevokeDragDrop(_hwnd)))
+               assert(0);
+}
+
+
 bool DesktopShellView::InitDragDrop()
 {
        CONTEXT("DesktopShellView::InitDragDrop()");
 
-       _pDropTarget = new DesktopDropTarget(_hwnd);
-
-       if (!_pDropTarget)
+       DesktopDropTarget * pDropTarget = new DesktopDropTarget(_hwnd);
+
+       if (!pDropTarget)
                return false;
 
-       _pDropTarget->AddRef();
-
-       if (FAILED(RegisterDragDrop(_hwnd, _pDropTarget))) {
-               _pDropTarget->Release();
-               _pDropTarget = NULL;
+       pDropTarget->AddRef();
+
+       if (FAILED(RegisterDragDrop(_hwnd, pDropTarget))) {
+               pDropTarget->Release();
                return false;
        }
-       else
-               _pDropTarget->Release();
 
        FORMATETC ftetc;
 
@@ -532,7 +537,8 @@
        ftetc.tymed = TYMED_HGLOBAL;
        ftetc.cfFormat = CF_HDROP;
 
-       _pDropTarget->AddSuportedFormat(ftetc);
+       pDropTarget->AddSuportedFormat(ftetc);
+       pDropTarget->Release();
 
        return true;
 }

Modified: trunk/reactos/base/shell/explorer/desktop/desktop.h
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/explorer/desktop/desktop.h?rev=41145&r1=41144&r2=41145&view=diff
==============================================================================
--- trunk/reactos/base/shell/explorer/desktop/desktop.h [iso-8859-1] (original)
+++ trunk/reactos/base/shell/explorer/desktop/desktop.h [iso-8859-1] Wed May 27 
21:35:02 2009
@@ -170,6 +170,7 @@
        typedef ExtContextMenuHandlerT<SubclassedWindow> super;
 
        DesktopShellView(HWND hwnd, IShellView* pShellView);
+       ~DesktopShellView();
 
        bool    InitDragDrop();
 
@@ -186,7 +187,6 @@
 
        void    refresh();
 
-       DesktopDropTarget* _pDropTarget;
        HWND    _hwndListView;
        int             _icon_algo;
 };

Reply via email to