From 06f368be54b9b092990517b9e0a6f98e1925a0fb Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 23 Apr 2021 22:37:15 +0100 Subject: [PATCH] Use wxON_BLOCK_EXIT_SET() in wxMSW wxSpinCtrl code Ensure that m_blockEvent flag is always reset on the scope exit. No real changes. --- src/msw/spinctrl.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/msw/spinctrl.cpp b/src/msw/spinctrl.cpp index e41003091f..2fd2525a67 100644 --- a/src/msw/spinctrl.cpp +++ b/src/msw/spinctrl.cpp @@ -37,6 +37,8 @@ #include "wx/msw/private.h" #include "wx/msw/private/winstyle.h" +#include "wx/scopeguard.h" + #if wxUSE_TOOLTIPS #include "wx/tooltip.h" #endif // wxUSE_TOOLTIPS @@ -447,18 +449,18 @@ wxString wxSpinCtrl::GetTextValue() const void wxSpinCtrl::SetValue(const wxString& text) { m_blockEvent = true; + wxON_BLOCK_EXIT_SET(m_blockEvent, false); if ( !::SetWindowText(GetBuddyHwnd(), text.c_str()) ) { wxLogLastError(wxT("SetWindowText(buddy)")); } - - m_blockEvent = false; } void wxSpinCtrl::SetValue(int val) { m_blockEvent = true; + wxON_BLOCK_EXIT_SET(m_blockEvent, false); wxSpinButton::SetValue(val); @@ -487,8 +489,6 @@ void wxSpinCtrl::SetValue(int val) } m_oldValue = GetValue(); - - m_blockEvent = false; } int wxSpinCtrl::GetValue() const