Kirix Support Forums

Removing and destroying toolbars with wxUpdateUIEvent

Please post all general questions, comments, bug reports, and any other wxAUI feedback here.

Removing and destroying toolbars with wxUpdateUIEvent

Postby fteicht on Wed Oct 20, 2010 1:48 pm

Hi all,

My application needs to create or to delete wxAuiToolBar objects on the fly depending on the current status of the application.
Some toolbars are connected to wxUpdateUIEvent to ease the way buttons are enabled or disabled.
When I want to remove and free the memory allocated to a wxAuiToolBar object, I use the following code:

Code: Select all
m_pAuiManager->GetPane(m_pAuiToolBar).Hide();
m_pAuiManager->DetachPane(m_pAuiToolBar);
m_pAuiToolBar->Destroy();


This code works fine on condition that the toolbar is not floating or is not connected to some wxUpdateUIEvents ; otherwise I get a segfault (at least on GTK). If the toolbar is docked, there is no problem, whatever wxUpdateUIEvents are connected or not.
I tried to disable the toolbar's event handler with
Code: Select all
m_pAuiToolBar->SetEvtHandlerEnable(false)
but still got a segfault when destroying the toolbar.

Any ideas?

Thank you very much in advance!
Florent
fteicht
Registered User
 
Posts: 2
Joined: Wed Oct 20, 2010 1:34 pm

Re: Removing and destroying toolbars with wxUpdateUIEvent

Postby fteicht on Thu Oct 21, 2010 3:05 am

I have found a workaround that seems to work:
Code: Select all
m_pAuiManager->GetPane(m_pAuiToolBar).Hide();
m_pAuiManager->GetPane(m_pAuiToolBar).DestroyOnClose(true);
m_pAuiToolBar.Close(true);

Could someone confirm please that the memory allocated to m_pAuiToolBar is freed?

Thanks!
Florent
fteicht
Registered User
 
Posts: 2
Joined: Wed Oct 20, 2010 1:34 pm

Return to wxAUI Questions, Thoughts & Feedback