MGR: Re-introduce the OnEndSession event handler.

This commit is contained in:
Rom Walton 2014-03-05 17:23:40 -05:00
parent 7ee5fe3423
commit 1ea098fb3d
2 changed files with 27 additions and 10 deletions

View File

@ -52,16 +52,6 @@
#include "sg_BoincSimpleFrame.h" #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; bool s_bSkipExitConfirmation = false;
#ifdef __WXMAC__ #ifdef __WXMAC__
@ -104,6 +94,7 @@ OSErr QuitAppleEventHandler( const AppleEvent *appleEvt, AppleEvent* reply, UInt
wxGetApp().GetFrame()->GetEventHandler()->AddPendingEvent(evt); wxGetApp().GetFrame()->GetEventHandler()->AddPendingEvent(evt);
return noErr; return noErr;
} }
#endif #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() { bool CBOINCGUIApp::OnInit() {
// Initialize globals // Initialize globals
#ifdef SANDBOX #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() { void CBOINCGUIApp::OnFatalException() {
wxDebugReportCompress* report = new wxDebugReportCompress; wxDebugReportCompress* report = new wxDebugReportCompress;

View File

@ -50,6 +50,7 @@ class CBOINCGUIApp : public wxApp {
protected: protected:
int OnExit(); int OnExit();
void OnEndSession(wxCloseEvent& event);
void OnFatalException(); void OnFatalException();