Use wxON_BLOCK_EXIT_SET() in wxMSW wxSpinCtrl code

Ensure that m_blockEvent flag is always reset on the scope exit.

No real changes.
This commit is contained in:
Vadim Zeitlin
2021-04-23 22:37:15 +01:00
parent 8fc2d44004
commit 06f368be54

View File

@@ -37,6 +37,8 @@
#include "wx/msw/private.h" #include "wx/msw/private.h"
#include "wx/msw/private/winstyle.h" #include "wx/msw/private/winstyle.h"
#include "wx/scopeguard.h"
#if wxUSE_TOOLTIPS #if wxUSE_TOOLTIPS
#include "wx/tooltip.h" #include "wx/tooltip.h"
#endif // wxUSE_TOOLTIPS #endif // wxUSE_TOOLTIPS
@@ -447,18 +449,18 @@ wxString wxSpinCtrl::GetTextValue() const
void wxSpinCtrl::SetValue(const wxString& text) void wxSpinCtrl::SetValue(const wxString& text)
{ {
m_blockEvent = true; m_blockEvent = true;
wxON_BLOCK_EXIT_SET(m_blockEvent, false);
if ( !::SetWindowText(GetBuddyHwnd(), text.c_str()) ) if ( !::SetWindowText(GetBuddyHwnd(), text.c_str()) )
{ {
wxLogLastError(wxT("SetWindowText(buddy)")); wxLogLastError(wxT("SetWindowText(buddy)"));
} }
m_blockEvent = false;
} }
void wxSpinCtrl::SetValue(int val) void wxSpinCtrl::SetValue(int val)
{ {
m_blockEvent = true; m_blockEvent = true;
wxON_BLOCK_EXIT_SET(m_blockEvent, false);
wxSpinButton::SetValue(val); wxSpinButton::SetValue(val);
@@ -487,8 +489,6 @@ void wxSpinCtrl::SetValue(int val)
} }
m_oldValue = GetValue(); m_oldValue = GetValue();
m_blockEvent = false;
} }
int wxSpinCtrl::GetValue() const int wxSpinCtrl::GetValue() const