On 9/21/2021 8:09 AM, Vadim Zeitlin wrote:
> On Mon, 20 Sep 2021 17:12:04 -0700 David Connet wrote:
>
> DC> I'm using a listctrl in report mode, multiselection allowed. Because of
> DC>
https://trac.wxwidgets.org/ticket/4541, I added a
> DC> wxEVT_COMMAND_LIST_ITEM_FOCUSED binding (so I can update various other
> DC> controls).
> DC>
> DC> On Mac and unix (ubuntu/gtk), this crashes on dialog destruction - I
> DC> tracked it down to receiving a focused event callback >after< the
> DC> destroyed event.
>
> Strange that it happens for a generic control. Can you check where is this
> focus event generated from?
>
> DC> As a workaround, I have added
> DC>
> DC> m_ctrlList->Bind(wxEVT_DESTROY, [this](wxWindowDestroyEvent& evt) {
> DC> m_ctrlList->Unbind(wxEVT_COMMAND_LIST_ITEM_FOCUSED,
> DC> &MyDialog::OnListItemFocused, this);
> DC> });
> DC>
> DC> and that seems to solve the Mac issue. On Ubuntu, I get a "corrupted
> DC> double-linked list" fault on Unbind - but, technically, I don't support
> DC> that platform, so I'm not too worried about that right now...
>
> Personally, I would be really worried about memory corruption anywhere.
This is always in some gtk code - eventually I'll get around to looking
at it, but since it doesn't affect Windows/Mac, it's pretty low on my list.
> DC> I'll try to get a bug written up and see if I can repro in a sample,
>
> Yes, this would be as useful as always, TIA!
So it looks like the event is being percolated up via DoDeleteAllItems,
ResetCurrent, ChangeCurrent, SendNotify
I put tracing into the listctrl sample, but don't see the focused
message turn up there after the destroy.
AHHA!
The difference is between using the event table and Bind. WHen I changed
the sample to bind to the focused event instead of the table, then I get
the focused event in the sample _after_ the destroy.