diff --git a/checkin_notes b/checkin_notes index 6a9db83c19..e8b0b13fa9 100644 --- a/checkin_notes +++ b/checkin_notes @@ -2999,9 +2999,12 @@ Charlie 12 Mar 2009 - MGR: Simplify the fixes for saving and restoring window sizes and other settings; eliminate unnecessary new events EVT_FRAME_RESTORESTATE and EVT_FRAME_SAVESTATE, etc; call SaveState() and RestoreState() directly. + - MGR: Handle EVT_END_SESSION event to call SaveState() on Windows logout + or shutdown; this fixes a long-standing problem where current settings + were not being saved. clientgui/ AdvancedFrame.cpp, .h BOINCBaseFrame.cpp, .h - BOINCGUIApp.cpp + BOINCGUIApp.cpp, .h sg_BoincSimpleGUI.cpp, .h diff --git a/clientgui/AdvancedFrame.h b/clientgui/AdvancedFrame.h index 4895258d2d..dd5acc659c 100644 --- a/clientgui/AdvancedFrame.h +++ b/clientgui/AdvancedFrame.h @@ -101,6 +101,8 @@ public: void ResetReminderTimers(); + bool SaveState(); + wxTimer* m_pRefreshStateTimer; wxTimer* m_pFrameRenderTimer; @@ -131,7 +133,6 @@ private: bool CreateStatusbar(); bool DeleteStatusbar(); - bool SaveState(); bool RestoreState(); void SaveWindowDimensions(); diff --git a/clientgui/BOINCBaseFrame.h b/clientgui/BOINCBaseFrame.h index 0dfd71001f..a125ca5943 100644 --- a/clientgui/BOINCBaseFrame.h +++ b/clientgui/BOINCBaseFrame.h @@ -93,6 +93,8 @@ public: bool Show( bool bShow = true ); + virtual bool SaveState(); + protected: CBOINCDialUpManager* m_pDialupManager; @@ -112,7 +114,6 @@ protected: virtual int _GetCurrentViewPage(); - virtual bool SaveState(); virtual bool RestoreState(); DECLARE_EVENT_TABLE() diff --git a/clientgui/BOINCGUIApp.cpp b/clientgui/BOINCGUIApp.cpp index 93145ce9d6..c91081dc14 100644 --- a/clientgui/BOINCGUIApp.cpp +++ b/clientgui/BOINCGUIApp.cpp @@ -68,6 +68,7 @@ IMPLEMENT_DYNAMIC_CLASS(CBOINCGUIApp, wxApp) BEGIN_EVENT_TABLE (CBOINCGUIApp, wxApp) EVT_RPC_FINISHED(CBOINCGUIApp::OnRPCFinished) + EVT_END_SESSION(CBOINCGUIApp::OnSystemShutDown) END_EVENT_TABLE () @@ -734,6 +735,17 @@ void CBOINCGUIApp::OnRPCFinished( CRPCFinishedEvent& event ) { } +// Ensure our settings are saved on Windows logout or shutdown +// This is never called on the Mac. +void CBOINCGUIApp::OnSystemShutDown( wxCloseEvent& event ) { + if (m_pFrame) { + m_pFrame->SaveState(); + } + + event.Skip(); +} + + int CBOINCGUIApp::UpdateSystemIdleDetection() { #ifdef __WXMSW__ return BOINCGetIdleTickCount(); diff --git a/clientgui/BOINCGUIApp.h b/clientgui/BOINCGUIApp.h index 79461cdfa3..8ea82155a8 100644 --- a/clientgui/BOINCGUIApp.h +++ b/clientgui/BOINCGUIApp.h @@ -164,6 +164,7 @@ public: bool ShowCurrentGUI() { return SetActiveGUI(m_iGUISelected, true); } void OnRPCFinished( CRPCFinishedEvent& event ); + void OnSystemShutDown( wxCloseEvent &event ); int ConfirmExit(); diff --git a/clientgui/sg_BoincSimpleGUI.h b/clientgui/sg_BoincSimpleGUI.h index 95803b51f4..ea02e9bcf2 100644 --- a/clientgui/sg_BoincSimpleGUI.h +++ b/clientgui/sg_BoincSimpleGUI.h @@ -122,6 +122,8 @@ public: void SetMsgsDlgOpen(CDlgMessages* newDlgPtr) { dlgMsgsPtr = newDlgPtr; } bool isMessagesDlgOpen() { return (dlgMsgsPtr != NULL); } + bool SaveState(); + protected: virtual int _GetCurrentViewPage(); @@ -135,7 +137,6 @@ protected: #endif private: - bool SaveState(); CDlgMessages* dlgMsgsPtr; DECLARE_EVENT_TABLE()