diff --git a/ZRCola/zrcolaapp.cpp b/ZRCola/zrcolaapp.cpp index e4d24f6..6e46e65 100644 --- a/ZRCola/zrcolaapp.cpp +++ b/ZRCola/zrcolaapp.cpp @@ -174,6 +174,7 @@ bool ZRColaApp::OnInit() wxSocketBase::Initialize(); m_mainWnd = new wxZRColaFrame(); + m_mainWnd->m_panel->RestoreFromStateFile(); m_mainWnd->Show(); return true; diff --git a/ZRCola/zrcolacomppnl.cpp b/ZRCola/zrcolacomppnl.cpp index 5d13b5d..1cac2d7 100644 --- a/ZRCola/zrcolacomppnl.cpp +++ b/ZRCola/zrcolacomppnl.cpp @@ -45,7 +45,22 @@ wxZRColaComposerPanel::wxZRColaComposerPanel(wxWindow* parent) : m_destination->SetMargins(FromDIP(wxPoint(5, 2))); m_source->PushEventHandler(&m_keyhandler); +} + +wxZRColaComposerPanel::~wxZRColaComposerPanel() +{ + m_source->PopEventHandler(); + + // This is a controlled exit. Purge saved state. + wxString fileName(GetStateFileName()); + if (wxFileExists(fileName)) + wxRemoveFile(fileName); +} + + +void wxZRColaComposerPanel::RestoreFromStateFile() +{ // Restore the previously saved state (if exists). wxString fileName(GetStateFileName()); if (wxFileExists(fileName)) { @@ -83,17 +98,6 @@ wxZRColaComposerPanel::wxZRColaComposerPanel(wxWindow* parent) : } -wxZRColaComposerPanel::~wxZRColaComposerPanel() -{ - m_source->PopEventHandler(); - - // This is a controlled exit. Purge saved state. - wxString fileName(GetStateFileName()); - if (wxFileExists(fileName)) - wxRemoveFile(fileName); -} - - void wxZRColaComposerPanel::SynchronizePanels() { if (m_sourceChanged) { @@ -193,7 +197,6 @@ void wxZRColaComposerPanel::SynchronizePanels() } - void wxZRColaComposerPanel::OnSourcePaint(wxPaintEvent& event) { event.Skip(); diff --git a/ZRCola/zrcolacomppnl.h b/ZRCola/zrcolacomppnl.h index 9044857..5d26f37 100644 --- a/ZRCola/zrcolacomppnl.h +++ b/ZRCola/zrcolacomppnl.h @@ -49,6 +49,7 @@ public: wxZRColaComposerPanel(wxWindow* parent); virtual ~wxZRColaComposerPanel(); + void RestoreFromStateFile(); void SynchronizePanels(); friend class wxPersistentZRColaComposerPanel; // Allow saving/restoring window state.