diff options
| author | Albrecht Schlosser <albrechts.fltk@online.de> | 2022-12-06 16:35:36 +0100 |
|---|---|---|
| committer | Albrecht Schlosser <albrechts.fltk@online.de> | 2022-12-10 15:03:30 +0100 |
| commit | 8dea6505e92a93156820ea24f1256f08cf2b9e8f (patch) | |
| tree | 1b8c796048d5267b2fa5bbd2970a2a24cf8e9bb1 /src | |
| parent | 98d97daf112906fe1732c6a7d9c5db946e0e8df5 (diff) | |
Windows: fix memory leak caused by RegisterDragDrop (#569)
- call RevokeDragDrop() when the window is hidden
- do not delete the *static* FLDropTarget object
Diffstat (limited to 'src')
| -rw-r--r-- | src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx | 3 | ||||
| -rw-r--r-- | src/fl_dnd_win32.cxx | 7 |
2 files changed, 6 insertions, 4 deletions
diff --git a/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx b/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx index 45e5cb39e..8a789bd1d 100644 --- a/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx +++ b/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx @@ -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 diff --git a/src/fl_dnd_win32.cxx b/src/fl_dnd_win32.cxx index 65a9a81dc..1c76558ae 100644 --- a/src/fl_dnd_win32.cxx +++ b/src/fl_dnd_win32.cxx @@ -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) { |
