DropTarget object dereferencing twice in wxWindow (Issue #26387)

14 views
Skip to first unread message

Paride Zavoli

unread,
Apr 16, 2026, 8:29:59 AM (8 days ago) Apr 16
to wx-...@googlegroups.com, Subscribed
pzavoli71 created an issue (wxWidgets/wxWidgets#26387)

Description

If a wxDropTarget is set on a wxWindow, when the window is destroyed, the wxDropTarget is de-referenced twice, with an exception occured at the second attempt.

Bug description:

This occurs because in the HandleDestroy() method of wxWindowMSW (row 4362 of msw/window.cpp) there is wxDELETE(m_dropTarget) without setting m_dropTarget = null and the same is executed in wxWindowBase destructor (row 515 of common/wincmn.cpp)

Expected vs observed behaviour:

To fix this behaviour it should be enough to put the instruction m_dropTarget = nullptr after the delete instruction in HandleDestroy() so the second delete would takes no effect.

To Reproduce:

  1. wxWindow->SetDropTarget(new MyDropTarget());
  2. Close the application
  3. Exception occurs

Platform and version information

  • wxWidgets version: 3.2.2
  • wxWidgets port: wxMSW
  • OS: Windows 11


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26387@github.com>

VZ

unread,
Apr 16, 2026, 10:23:47 AM (8 days ago) Apr 16
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#26387)

The trouble with this analysis is that wxDELETE does set the pointer to null, so I don't see how can this be true and I definitely don't see any crashes in the dnd sample. Please provide a patch reproducing the problem there.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26387/4260817127@github.com>

Reply all
Reply to author
Forward
0 new messages