Kirix Support Forums

Problems with detaching a pane

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

Problems with detaching a pane

Postby BigFreeze on Tue Oct 16, 2007 1:32 am

Hi,

I'm relatively new to wxAui and have a problem while detaching a pane.
Following situation: A add a pane to the wxAuiManager. The close event is sent to that window, I set with SetManagedWindow. In the method that is called with the close event, I want to detach this pane from the wxAuiManager.

But that causes a runtime error in wxFrameManager::ClosePane at line 1093 in

Code: Select all
    if (pane_info.window && pane_info.window->IsShown())
    {
        pane_info.window->Show(false);
    }


I used that source code to detach the pane:

Code: Select all
  if (evt.pane->name == wxT("Suche"))
    {
    if (m_pWScroll)
      {
      m_mgr->DetachPane(m_pWScroll);
      m_pWScroll->Destroy();
      m_pWScroll = NULL;
      m_mgr->Update();
      }
    }


where m_mgr is wxAuiManager and m_pWScroll is the frame, that I closed. What have I done wrong?

Best regards, BigFreeze
BigFreeze
Registered User
 
Posts: 3
Joined: Tue Oct 16, 2007 1:22 am

Re: Problems with detaching a pane

Postby Ben on Tue Oct 16, 2007 9:39 am

Hi there,

Thanks for the interesting point. Basically, aui was assuming that you wouldn't detach a pane in the close window handler. I'm going to add a check for that case right now to the 2.8.x branch and the trunk.

Thanks,
Ben
Ben Williams
Kirix Support Team
User avatar
Ben
Kirix Support Team
 
Posts: 525
Joined: Mon Dec 19, 2005 6:29 am

Re: Problems with detaching a pane

Postby BigFreeze on Wed Oct 17, 2007 3:19 am

Thanks for your response, Ben.

But what can I do to avoid that runtime error? I want to remove that frame from the manager to open it again. When I just close it and want to open it again, I get the information, that a frame with this name already exists. Is there another solution?

Best regards, BigFreeze
BigFreeze
Registered User
 
Posts: 3
Joined: Tue Oct 16, 2007 1:22 am

Re: Problems with detaching a pane

Postby Ben on Mon Oct 22, 2007 6:44 am

Did you get the latest code from wxWidgets svn? I believe I fixed this problem there.

All the best,
Ben
Ben Williams
Kirix Support Team
User avatar
Ben
Kirix Support Team
 
Posts: 525
Joined: Mon Dec 19, 2005 6:29 am

Re: Problems with detaching a pane

Postby BigFreeze on Wed Oct 24, 2007 1:07 am

Hi Ben,

you wrote, that you fixed that problem in the latest code from wxWidgets SVN. Well, I didn't get the code, but found another solution.

There is called an event

EVT_AUI_PANE_CLOSE(MainAppFrame::OnPaneClose)

in the event table when I close a pane. And that calls the method

Code: Select all
void MainAppFrame::OnPaneClose(wxAuiManagerEvent& event)
{
  wxWindow* wnd = event.pane->window;
  m_mgr->DetachPane(wnd);
  wnd->Destroy();
  event.Veto();

  m_mgr->Update();
}


where m_mgr is wxAuiManager.
If I do not stop the event, it calls DetachPane itself. I do not know, why. So I have to detach the pane myself from the manager and destroy it.

If I do not call wnd->Destroy(), the window is still handled in the manager. With the Destroy() method the window is not handled anymore and the GetAllPanes() method returns the correct number of panes, that are shown or hidden.

Anyway, Ben, thanks for your work.

Best regards, BigFreeze
BigFreeze
Registered User
 
Posts: 3
Joined: Tue Oct 16, 2007 1:22 am

Return to wxAUI Questions, Thoughts & Feedback