wxListCtrl crash on mac/unix

22 views
Skip to first unread message

David Connet

unread,
Sep 20, 2021, 8:12:12 PM9/20/21
to wx-dev
I'm using a listctrl in report mode, multiselection allowed. Because of
https://trac.wxwidgets.org/ticket/4541, I added a
wxEVT_COMMAND_LIST_ITEM_FOCUSED binding (so I can update various other
controls).

On Mac and unix (ubuntu/gtk), this crashes on dialog destruction - I
tracked it down to receiving a focused event callback >after< the
destroyed event.

As a workaround, I have added

    m_ctrlList->Bind(wxEVT_DESTROY, [this](wxWindowDestroyEvent& evt) {
        m_ctrlList->Unbind(wxEVT_COMMAND_LIST_ITEM_FOCUSED,
&MyDialog::OnListItemFocused, this);
    });

and that seems to solve the Mac issue. On Ubuntu, I get a "corrupted
double-linked list" fault on Unbind - but, technically, I don't support
that platform, so I'm not too worried about that right now...

I'll try to get a bug written up and see if I can repro in a sample, but
I have to run out for my dog's agility class now!

Dave

Vadim Zeitlin

unread,
Sep 21, 2021, 11:09:07 AM9/21/21
to wx-...@googlegroups.com
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.

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!

DC> but I have to run out for my dog's agility class now!

Wait, if it's his agility class, why do _you_ need to run?
VZ

David Connet

unread,
Sep 21, 2021, 11:31:51 AM9/21/21
to wx-...@googlegroups.com
On 9/21/2021 8:09 AM, Vadim Zeitlin wrote:
> DC> but I have to run out for my dog's agility class now!
>
> Wait, if it's his agility class, why do _you_ need to run?
> VZ

Because he's also training me! (After 20+ years of competing, you'd
_think_ I would know what to do...)

Dave

David Connet

unread,
Sep 21, 2021, 2:38:48 PM9/21/21
to wx-...@googlegroups.com
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.

Reply all
Reply to author
Forward
0 new messages