forked from bartvdbraak/blender
Fix #32046: GHOST_DropTargetWin32 memory leak, patch by Matt D.
This commit is contained in:
parent
989313e450
commit
195c520d05
@ -51,14 +51,10 @@ GHOST_DropTargetWin32::GHOST_DropTargetWin32(GHOST_WindowWin32 *window, GHOST_Sy
|
|||||||
m_cRef = 1;
|
m_cRef = 1;
|
||||||
m_hWnd = window->getHWND();
|
m_hWnd = window->getHWND();
|
||||||
m_draggedObjectType = GHOST_kDragnDropTypeUnknown;
|
m_draggedObjectType = GHOST_kDragnDropTypeUnknown;
|
||||||
|
|
||||||
// register our window as drop target
|
|
||||||
::RegisterDragDrop(m_hWnd, this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GHOST_DropTargetWin32::~GHOST_DropTargetWin32()
|
GHOST_DropTargetWin32::~GHOST_DropTargetWin32()
|
||||||
{
|
{
|
||||||
::RevokeDragDrop(m_hWnd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -271,6 +271,10 @@ GHOST_WindowWin32::GHOST_WindowWin32(
|
|||||||
// Register this window as a droptarget. Requires m_hWnd to be valid.
|
// Register this window as a droptarget. Requires m_hWnd to be valid.
|
||||||
// Note that OleInitialize(0) has to be called prior to this. Done in GHOST_SystemWin32.
|
// Note that OleInitialize(0) has to be called prior to this. Done in GHOST_SystemWin32.
|
||||||
m_dropTarget = new GHOST_DropTargetWin32(this, m_system);
|
m_dropTarget = new GHOST_DropTargetWin32(this, m_system);
|
||||||
|
if (m_dropTarget) {
|
||||||
|
::RegisterDragDrop(m_hWnd, m_dropTarget);
|
||||||
|
}
|
||||||
|
|
||||||
// Store a pointer to this class in the window structure
|
// Store a pointer to this class in the window structure
|
||||||
::SetWindowLongPtr(m_hWnd, GWL_USERDATA, (LONG_PTR) this);
|
::SetWindowLongPtr(m_hWnd, GWL_USERDATA, (LONG_PTR) this);
|
||||||
|
|
||||||
@ -415,7 +419,13 @@ GHOST_WindowWin32::~GHOST_WindowWin32()
|
|||||||
m_hDC = 0;
|
m_hDC = 0;
|
||||||
}
|
}
|
||||||
if (m_hWnd) {
|
if (m_hWnd) {
|
||||||
m_dropTarget->Release(); // frees itself.
|
if (m_dropTarget) {
|
||||||
|
// Disable DragDrop
|
||||||
|
RevokeDragDrop(m_hWnd);
|
||||||
|
// Release our reference of the DropTarget and it will delete itself eventually.
|
||||||
|
m_dropTarget->Release();
|
||||||
|
}
|
||||||
|
|
||||||
::DestroyWindow(m_hWnd);
|
::DestroyWindow(m_hWnd);
|
||||||
m_hWnd = 0;
|
m_hWnd = 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user