[wx-dev] #9708: wxEvtHandler - Dead event table entry used in
ProcessEvent
wxTrac
noreply at wxsite.net
Mon Jul 7 07:21:31 PDT 2008
Ticket URL: <http://trac.wxwidgets.org/ticket/9708>
#9708: wxEvtHandler - Dead event table entry used in ProcessEvent
---------------------------------------------+------------------------------
Reporter: arst | Owner: vadz
Type: defect | Status: new
Priority: normal | Milestone: 2.9.0
Component: base | Version: 2.9-svn
Keywords: wxEvtHandler Disconnect Connect | Blockedby:
Patch: 0 | Blocking:
---------------------------------------------+------------------------------
This happened in my app on closing a popup editor (which does a bit of
Connect/Disconnect). The crash happens inside
wxEvtHandler::SearchDynamicEventTable.
Looking at the source it's fairly clear what goes wrong:
{{{
// get next node before (maybe) calling the event handler as it
could
// call Disconnect() invalidating the current node
node = node->GetNext();
}}}
Well, also the next node may be disconnected by the event handler.
Some variant of weak ref mechanism is needed when traversing a list that
can be modified while traversing it. Maybe one could delay removing the
handlers from the list until it's been traversed (g_pendingDisconnects).
(My event handler did Skip() on the event. By detecting when I was doing
Disconnect() and then _not_ do Skip() I was able to work around it. But
that doesn't feel very solid).
Regards
// ATS.
--
Ticket URL: <http://trac.wxwidgets.org/ticket/9708>
More information about the wx-dev
mailing list