From 1ea098fb3d8b7406629f6bf54dc9d16970cfc588 Mon Sep 17 00:00:00 2001 From: Rom Walton Date: Wed, 5 Mar 2014 17:23:40 -0500 Subject: [PATCH] MGR: Re-introduce the OnEndSession event handler. --- clientgui/BOINCGUIApp.cpp | 36 ++++++++++++++++++++++++++---------- clientgui/BOINCGUIApp.h | 1 + 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/clientgui/BOINCGUIApp.cpp b/clientgui/BOINCGUIApp.cpp index 860a9e1109..d3a41a26eb 100644 --- a/clientgui/BOINCGUIApp.cpp +++ b/clientgui/BOINCGUIApp.cpp @@ -52,16 +52,6 @@ #include "sg_BoincSimpleFrame.h" -DEFINE_EVENT_TYPE(wxEVT_RPC_FINISHED) - -IMPLEMENT_APP(CBOINCGUIApp) -IMPLEMENT_DYNAMIC_CLASS(CBOINCGUIApp, wxApp) - -BEGIN_EVENT_TABLE (CBOINCGUIApp, wxApp) - EVT_ACTIVATE_APP(CBOINCGUIApp::OnActivateApp) - EVT_RPC_FINISHED(CBOINCGUIApp::OnRPCFinished) -END_EVENT_TABLE () - bool s_bSkipExitConfirmation = false; #ifdef __WXMAC__ @@ -104,6 +94,7 @@ OSErr QuitAppleEventHandler( const AppleEvent *appleEvt, AppleEvent* reply, UInt wxGetApp().GetFrame()->GetEventHandler()->AddPendingEvent(evt); return noErr; } + #endif @@ -124,6 +115,17 @@ void BOINCAssertHandler(const wxString &file, int line, const wxString &func, co } +DEFINE_EVENT_TYPE(wxEVT_RPC_FINISHED) + +IMPLEMENT_APP(CBOINCGUIApp) +IMPLEMENT_DYNAMIC_CLASS(CBOINCGUIApp, wxApp) + +BEGIN_EVENT_TABLE (CBOINCGUIApp, wxApp) + EVT_ACTIVATE_APP(CBOINCGUIApp::OnActivateApp) + EVT_RPC_FINISHED(CBOINCGUIApp::OnRPCFinished) + EVT_END_SESSION(CBOINCGUIApp::OnEndSession) +END_EVENT_TABLE () + bool CBOINCGUIApp::OnInit() { // Initialize globals #ifdef SANDBOX @@ -551,6 +553,20 @@ int CBOINCGUIApp::OnExit() { } +// Work around a bug in wxWidgets call OnExit() when Windows is shut down. +// +void CBOINCGUIApp::OnEndSession(wxCloseEvent& ) { + s_bSkipExitConfirmation = true; + + CBOINCBaseFrame* pFrame = wxGetApp().GetFrame(); + wxCommandEvent evt(wxEVT_COMMAND_MENU_SELECTED, wxID_EXIT); + // The event loop has already been stopped, + // so we must call OnExit directly + pFrame->OnExit(evt); + OnExit(); +} + + void CBOINCGUIApp::OnFatalException() { wxDebugReportCompress* report = new wxDebugReportCompress; diff --git a/clientgui/BOINCGUIApp.h b/clientgui/BOINCGUIApp.h index ab56c36f0b..4b49e28539 100644 --- a/clientgui/BOINCGUIApp.h +++ b/clientgui/BOINCGUIApp.h @@ -50,6 +50,7 @@ class CBOINCGUIApp : public wxApp { protected: int OnExit(); + void OnEndSession(wxCloseEvent& event); void OnFatalException();