Windows: fix memory leak caused by RegisterDragDrop (#569)

- call RevokeDragDrop() when the window is hidden
- do not delete the *static* FLDropTarget object
This commit is contained in:
Albrecht Schlosser 2022-12-06 16:35:36 +01:00
parent 98d97daf11
commit 8dea6505e9
2 changed files with 6 additions and 4 deletions

View File

@ -470,6 +470,9 @@ void Fl_WinAPI_Window_Driver::hide() {
return;
}
// Issue #569: undo RegisterDragDrop()
RevokeDragDrop((HWND)ip->xid);
// make sure any custom icons get freed
// icons(NULL, 0); // free_icons() is called by the Fl_Window destructor
// this little trick keeps the current clipboard alive, even if we are about

View File

@ -1,7 +1,7 @@
//
// Drag & Drop code for the Fast Light Tool Kit (FLTK).
//
// Copyright 1998-2018 by Bill Spitzak and others.
// Copyright 1998-2022 by Bill Spitzak and others.
//
// This library is free software. Distribution and use rights are outlined in
// the file "COPYING" which should have been included with this file. If this
@ -54,7 +54,7 @@ Fl_Window *fl_dnd_target_window = 0;
*/
class FLDropTarget : public IDropTarget
{
DWORD m_cRefCount;
DWORD m_cRefCount; // for "statistics" only (issue #569)
DWORD lastEffect;
int px, py;
public:
@ -74,8 +74,7 @@ public:
ULONG STDMETHODCALLTYPE Release() {
long nTemp;
nTemp = --m_cRefCount;
if(nTemp==0)
delete this;
// this is a static object, do not 'delete this' (issue #569)
return nTemp;
}
HRESULT STDMETHODCALLTYPE DragEnter( IDataObject *pDataObj, DWORD /*grfKeyState*/, POINTL pt, DWORD *pdwEffect) {