Remove the native toolbar from the frame in Destroy() rather than the destructor, as removing it in the destructor causes resize / repaint events to fire on the native control, which then goes to wx controls being deleted.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62988 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Kevin Ollivier
2009-12-25 20:43:43 +00:00
parent 849754a451
commit 1665389a9a
4 changed files with 43 additions and 32 deletions

View File

@@ -926,26 +926,17 @@ bool wxToolBar::Create(
wxToolBar::~wxToolBar()
{
#if wxOSX_USE_NATIVE_TOOLBAR
if (m_macToolbar != NULL)
CFIndex count = CFGetRetainCount( m_macToolbar ) ;
// Leopard seems to have one refcount more, so we cannot check reliably at the moment
if ( UMAGetSystemVersion() < 0x1050 )
{
// if this is the installed toolbar, then deinstall it
if (m_macUsesNativeToolbar)
MacInstallNativeToolbar( false );
CFIndex count = CFGetRetainCount( m_macToolbar ) ;
// Leopard seems to have one refcount more, so we cannot check reliably at the moment
if ( UMAGetSystemVersion() < 0x1050 )
if ( count != 1 )
{
if ( count != 1 )
{
wxFAIL_MSG("Reference count of native control was not 1 in wxToolBar destructor");
}
wxFAIL_MSG("Reference count of native control was not 1 in wxToolBar destructor");
}
CFRelease( (HIToolbarRef)m_macToolbar );
m_macToolbar = NULL;
}
#endif
CFRelease( (HIToolbarRef)m_macToolbar );
m_macToolbar = NULL;
}
bool wxToolBar::Show( bool show )
@@ -1135,7 +1126,7 @@ bool wxToolBar::MacInstallNativeToolbar(bool usesNative)
ShowHideWindowToolbar( tlw, false, false );
ChangeWindowAttributes( tlw, 0, kWindowToolbarButtonAttribute );
SetWindowToolbar( tlw, NULL );
MacUninstallNativeToolbar();
m_peer->SetVisibility( true );
}
@@ -1147,6 +1138,16 @@ bool wxToolBar::MacInstallNativeToolbar(bool usesNative)
// wxLogDebug( wxT(" --> [%lx] - result [%s]"), (long)this, bResult ? wxT("T") : wxT("F") );
return bResult;
}
void wxToolBar::MacUninstallNativeToolbar()
{
if (!m_macToolbar)
return;
WindowRef tlw = MAC_WXHWND(MacGetTopLevelWindowRef());
if (tlw)
SetWindowToolbar( tlw, NULL );
}
#endif
bool wxToolBar::Realize()