Opened 5 years ago

Closed 5 years ago

#11775 closed defect (fixed)

wxToolBar crashes in destructor

Reported by: norfolc Owned by:
Priority: high Milestone: 2.9.1
Component: wxOSX-Carbon Version: stable-latest
Keywords: wxToolBar, wxToolBook Cc:
Blocked By: Blocking:
Patch: yes

Description

This patch fixes crash in wxToolBar destructor in OSX Carbon version.
Passing NULL value to the CFRelease causes EXC_BAD_ACCESS.
So we need to check if m_macToolbar is not null.
This occurs if wxOSX_USE_NATIVE_TOOLBAR is not defined.

Attachments (1)

wxToolBar.patch download (1.2 KB) - added by norfolc 5 years ago.

Download all attachments as: .zip

Change History (4)

comment:1 Changed 5 years ago by vadz

  • Milestone set to 2.9.1

I don't even understand how can this code compile if wxOSX_USE_NATIVE_TOOLBAR is not defined as m_macToolbar is only declared when wxOSX_USE_NATIVE_TOOLBAR==1, any idea? Anyhow, the logical thing to do would seem to be to just enclose the entire dtor body in #if wxOSX_USE_NATIVE_TOOLBAR, would this fix the problem too?

comment:2 Changed 5 years ago by norfolc

  • Keywords wxToolBook added

sorry. I make a mistake. wxOSX_USE_NATIVE_TOOLBAR is defined, but m_macToolbar == NULL in case if it used in wxToolBook.
In this case parent->IsKindOf(CLASSINFO(wxFrame)) returns false and native toolbar is not created.
So, we need to leave a check for m_macToolbar != NULL and also we need to add #ifdef wxOSX_USE_NATIVE_TOOLBAR.

Changed 5 years ago by norfolc

comment:3 Changed 5 years ago by VZ

  • Resolution set to fixed
  • Status changed from new to closed

(In [63604]) Don't use m_macToolbar in wxOSX wxToolBar if it is NULL.

This fixes a crash when a native toolbar is not used by wxToolBar as it
happens when it's used by wxToolbook for example.

Closes #11775.

Note: See TracTickets for help on using tickets.