From 72f17ad7f0146647d5cd53d7ec3be621e2feefea Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 27 Nov 2018 17:08:11 +0000 Subject: [PATCH] Attempt to fix MSW Cancel-still-validates bug. Fixes: lp:1805361 * https://bugs.launchpad.net/kicad/+bug/1805361 --- common/widgets/unit_binder.cpp | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/common/widgets/unit_binder.cpp b/common/widgets/unit_binder.cpp index 48deab758b..16f26d1b84 100644 --- a/common/widgets/unit_binder.cpp +++ b/common/widgets/unit_binder.cpp @@ -92,17 +92,25 @@ void UNIT_BINDER::onSetFocus( wxFocusEvent& aEvent ) void UNIT_BINDER::onKillFocus( wxFocusEvent& aEvent ) { - auto textEntry = dynamic_cast( m_value ); - - if( m_allowEval && textEntry ) + if( aEvent.GetWindow() && aEvent.GetWindow()->GetId() == wxID_CANCEL ) { - if( m_eval.Process( textEntry->GetValue() ) ) - textEntry->ChangeValue( m_eval.Result() ); - - m_needsEval = false; + // Don't eval or validate when focus lost due to Cancel. While most platforms + // suppress KillFocus events after a Cancel, MSW (at least) does not. } + else + { + auto textEntry = dynamic_cast( m_value ); - Validate( true ); + if( m_allowEval && textEntry ) + { + if( m_eval.Process( textEntry->GetValue() ) ) + textEntry->ChangeValue( m_eval.Result() ); + + m_needsEval = false; + } + + Validate( true ); + } aEvent.Skip(); }