wxAuiManager persistence changed to resolve asserts in Win32 builds

This commit is contained in:
Simon Rozman 2016-05-25 00:07:34 +02:00
parent 38f47db6d6
commit 6733ef3cfc
5 changed files with 17 additions and 8 deletions

View File

@ -62,7 +62,7 @@
<event name="OnAuiPaneRestore"></event>
<event name="OnAuiRender"></event>
<event name="OnChar"></event>
<event name="OnClose"></event>
<event name="OnClose">OnClose</event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnHibernate"></event>

View File

@ -69,10 +69,6 @@ wxZRColaFrame::wxZRColaFrame() :
m_toolbarCompose->SetWindowStyleFlag(m_toolbarCompose->GetWindowStyleFlag() | wxAUI_TB_HORIZONTAL);
}
// Restore the wxAuiManager's state here to keep symmetric with save in the destructor below.
// See the comment in destructor why.
wxPersistentAuiManager(&m_mgr).Restore();
// Load main window icons.
#ifdef __WINDOWS__
wxIcon icon_small(wxT("00_zrcola.ico"), wxBITMAP_TYPE_ICO_RESOURCE, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON));
@ -135,6 +131,9 @@ wxZRColaFrame::wxZRColaFrame() :
entries[0].Set(wxACCEL_NORMAL, WXK_F4, wxID_FOCUS_CHARACTER_CATALOG);
SetAcceleratorTable(wxAcceleratorTable(_countof(entries), entries));
}
// Restore persistent state of wxAuiManager manually, since m_mgr is not on the heap.
wxPersistentAuiManager(&m_mgr).Restore();
}
@ -161,10 +160,16 @@ wxZRColaFrame::~wxZRColaFrame()
m_taskBarIcon->Disconnect(wxEVT_TASKBAR_LEFT_DOWN, wxTaskBarIconEventHandler(wxZRColaFrame::OnTaskbarIconClick), NULL, this);
delete m_taskBarIcon;
}
}
// Save wxAuiManager's state before return to parent's destructor.
// Since the later calls m_mgr.UnInit() the regular persistence mechanism is useless to save wxAuiManager's state.
wxPersistentAuiManager((wxAuiManager*)&m_mgr).Save();
void wxZRColaFrame::OnClose(wxCloseEvent& event)
{
event.Skip();
// Save wxAuiManager's state before destructor.
// Since the destructor calls m_mgr.UnInit() the regular persistence mechanism is useless to save wxAuiManager's state.
wxPersistentAuiManager(&m_mgr).Save();
}

View File

@ -65,6 +65,7 @@ public:
friend class wxZRColaComposerPanel;
protected:
virtual void OnClose(wxCloseEvent& event);
void OnExit(wxCommandEvent& event);
void OnForwardEventUpdate(wxUpdateUIEvent& event);
void OnForwardEvent(wxCommandEvent& event);

View File

@ -190,6 +190,7 @@ wxZRColaFrameBase::wxZRColaFrameBase( wxWindow* parent, wxWindowID id, const wxS
this->Centre( wxBOTH );
// Connect Events
this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( wxZRColaFrameBase::OnClose ) );
this->Connect( wxEVT_ICONIZE, wxIconizeEventHandler( wxZRColaFrameBase::OnIconize ) );
this->Connect( wxEVT_IDLE, wxIdleEventHandler( wxZRColaFrameBase::OnIdle ) );
}
@ -197,6 +198,7 @@ wxZRColaFrameBase::wxZRColaFrameBase( wxWindow* parent, wxWindowID id, const wxS
wxZRColaFrameBase::~wxZRColaFrameBase()
{
// Disconnect Events
this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( wxZRColaFrameBase::OnClose ) );
this->Disconnect( wxEVT_ICONIZE, wxIconizeEventHandler( wxZRColaFrameBase::OnIconize ) );
this->Disconnect( wxEVT_IDLE, wxIdleEventHandler( wxZRColaFrameBase::OnIdle ) );

View File

@ -91,6 +91,7 @@ class wxZRColaFrameBase : public wxFrame
wxStatusBar* m_statusBar;
// Virtual event handlers, overide them in your derived class
virtual void OnClose( wxCloseEvent& event ) { event.Skip(); }
virtual void OnIconize( wxIconizeEvent& event ) { event.Skip(); }
virtual void OnIdle( wxIdleEvent& event ) { event.Skip(); }