From ea1015596c5f63fa7bd2ffcaf9e49820722f1ec6 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Mon, 3 Oct 2016 14:29:42 -0400 Subject: [PATCH] Bug1511: REBUILD WXWIDGETS: Mac Quit via tooldock doesn't crash... ... in case at least three projects are open, or skip save prompts either, in case at least two projects with unsaved changes are open. --- mac/Build.txt | 1 + mac/wxMac_additions/tooldock-quit.patch | 57 +++++++++++++++++++++++++ src/AudacityApp.cpp | 17 +++++++- src/AudacityApp.h | 1 + 4 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 mac/wxMac_additions/tooldock-quit.patch diff --git a/mac/Build.txt b/mac/Build.txt index 3c2cd95f0..b5f970f67 100644 --- a/mac/Build.txt +++ b/mac/Build.txt @@ -41,6 +41,7 @@ http://forum.audacityteam.org/viewtopic.php?p=303835#p303835 . patch -p0 -i /mac/wxMac_additions/pinch-spread.patch . patch -p0 -i /mac/wxMac_additions/focusrings.patch . patch -p0 -i /mac/wxMac_additions/wxMac-3.0.2-wxaccessible.patch . + patch -p0 -i /mac/wxMac_additions/tooldock-quit.patch . 10) And finally build/install wxWidgets: diff --git a/mac/wxMac_additions/tooldock-quit.patch b/mac/wxMac_additions/tooldock-quit.patch new file mode 100644 index 000000000..e370ad76a --- /dev/null +++ b/mac/wxMac_additions/tooldock-quit.patch @@ -0,0 +1,57 @@ +From 343528d045e805b84e2c4df2bacdf4d319906084 Mon Sep 17 00:00:00 2001 +From: Paul Licameli +Date: Mon, 3 Oct 2016 13:58:26 -0400 +Subject: [PATCH] Quitting app via Mac tooldock uses events, so behavior is + overridable + +--- + src/osx/carbon/app.cpp | 20 +++++++++++--------- + 1 file changed, 11 insertions(+), 9 deletions(-) + +diff --git a/src/osx/carbon/app.cpp b/src/osx/carbon/app.cpp +index 0926dbf..bdb78ca 100644 +--- src/osx/carbon/app.cpp ++++ src/osx/carbon/app.cpp +@@ -259,12 +259,9 @@ short wxApp::MacHandleAEOApp(const WXEVENTREF WXUNUSED(event) , WXEVENTREF WXUNU + + short wxApp::MacHandleAEQuit(const WXEVENTREF WXUNUSED(event) , WXEVENTREF WXUNUSED(reply)) + { +- wxCloseEvent event; +- wxTheApp->OnQueryEndSession(event); +- if ( !event.GetVeto() ) ++ if ( OSXOnShouldTerminate() ) + { +- wxCloseEvent event; +- wxTheApp->OnEndSession(event); ++ OSXOnWillTerminate(); + } + return noErr ; + } +@@ -421,15 +418,20 @@ void wxApp::OSXOnDidFinishLaunching() + + void wxApp::OSXOnWillTerminate() + { +- wxCloseEvent event; ++ wxCloseEvent event(wxEVT_END_SESSION, wxID_ANY); ++ event.SetEventObject(wxTheApp); + event.SetCanVeto(false); +- wxTheApp->OnEndSession(event); ++ ++ wxTheApp->ProcessEvent(event); + } + + bool wxApp::OSXOnShouldTerminate() + { +- wxCloseEvent event; +- wxTheApp->OnQueryEndSession(event); ++ wxCloseEvent event(wxEVT_QUERY_END_SESSION, wxID_ANY); ++ event.SetEventObject(wxTheApp); ++ event.SetCanVeto(true); ++ ++ wxTheApp->ProcessEvent(event); + return !event.GetVeto(); + } + #endif +-- +2.3.2 (Apple Git-55) + diff --git a/src/AudacityApp.cpp b/src/AudacityApp.cpp index 282afd372..47f492f97 100644 --- a/src/AudacityApp.cpp +++ b/src/AudacityApp.cpp @@ -744,7 +744,8 @@ void AudacityApp::MacNewFile() #define kAudacityAppTimerID 0 BEGIN_EVENT_TABLE(AudacityApp, wxApp) - EVT_QUERY_END_SESSION(AudacityApp::OnEndSession) + EVT_QUERY_END_SESSION(AudacityApp::OnQueryEndSession) + EVT_END_SESSION(AudacityApp::OnEndSession) EVT_TIMER(kAudacityAppTimerID, AudacityApp::OnTimer) #ifdef __WXMAC__ @@ -1974,6 +1975,20 @@ void AudacityApp::FindFilesInPathList(const wxString & pattern, } } +void AudacityApp::OnQueryEndSession(wxCloseEvent & event) +{ + bool mustVeto = false; + +#ifdef __WXMAC__ + mustVeto = wxDialog::OSXHasModalDialogsOpen(); +#endif + + if ( mustVeto ) + event.Veto(true); + else + OnEndSession(event); +} + void AudacityApp::OnEndSession(wxCloseEvent & event) { bool force = !event.CanVeto(); diff --git a/src/AudacityApp.h b/src/AudacityApp.h index 4eacac2fc..030fe7baa 100644 --- a/src/AudacityApp.h +++ b/src/AudacityApp.h @@ -205,6 +205,7 @@ class AudacityApp final : public wxApp { void OnMenuPreferences(wxCommandEvent & event); void OnMenuExit(wxCommandEvent & event); + void OnQueryEndSession(wxCloseEvent & event); void OnEndSession(wxCloseEvent & event); // Most Recently Used File support (for all platforms).