From 879ecefdaac73a0dec3a278062748ac4e53fee36 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Sat, 23 Apr 2016 08:49:11 -0400 Subject: [PATCH] Bug1318: ESC key or red close button should not leave the app unresponsive... ... I don't fully understand why this fixes it, but I could figure out what was different between ESC and Cancel button which did not have the problem. --- src/effects/Effect.cpp | 29 +++++++++++++++++------------ src/effects/Effect.h | 3 +++ 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/effects/Effect.cpp b/src/effects/Effect.cpp index 1737f806d..2a24f0696 100644 --- a/src/effects/Effect.cpp +++ b/src/effects/Effect.cpp @@ -3192,6 +3192,8 @@ void EffectUIHost::OnPaint(wxPaintEvent & WXUNUSED(evt)) void EffectUIHost::OnClose(wxCloseEvent & WXUNUSED(evt)) { + DoCancel(); + CleanupRealtime(); Hide(); @@ -3261,20 +3263,23 @@ void EffectUIHost::OnApply(wxCommandEvent & evt) return; } +void EffectUIHost::DoCancel() +{ + if (!mCancelled) { + mEffect->mUIResultID = wxID_CANCEL; + + if (IsModal()) + EndModal(false); + else + Hide(); + + mCancelled = true; + } +} + void EffectUIHost::OnCancel(wxCommandEvent & evt) { - mEffect->mUIResultID = evt.GetId(); - - if (IsModal()) - { - EndModal(false); - - Close(); - - return; - } - - Hide(); + DoCancel(); Close(); diff --git a/src/effects/Effect.h b/src/effects/Effect.h index fe33fdba8..5ea0b5bc9 100644 --- a/src/effects/Effect.h +++ b/src/effects/Effect.h @@ -596,6 +596,7 @@ private: void OnPaint(wxPaintEvent & evt); void OnClose(wxCloseEvent & evt); void OnApply(wxCommandEvent & evt); + void DoCancel(); void OnCancel(wxCommandEvent & evt); void OnDebug(wxCommandEvent & evt); void OnMenu(wxCommandEvent & evt); @@ -658,6 +659,8 @@ private: SelectedRegion mRegion; double mPlayPos; + bool mCancelled{}; + DECLARE_EVENT_TABLE(); };