From e2d2b367af1da9d84c82812ecf47c7e06707e655 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 25 Apr 2021 19:13:22 +0100 Subject: [PATCH] Always initialize m_format in DetermineDigits() It doesn't seem right to leave it unchanged when increment is outside of [0, 1] interval, we should still set it to something in this case. And doing this makes it unnecessary and redundant to initialize m_format in Init(), as it will be always done when DetermineDigits() is called from Create() anyhow. --- include/wx/generic/spinctlg.h | 1 - src/generic/spinctlg.cpp | 7 ++++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/include/wx/generic/spinctlg.h b/include/wx/generic/spinctlg.h index 4c64ade837..c00ed843eb 100644 --- a/include/wx/generic/spinctlg.h +++ b/include/wx/generic/spinctlg.h @@ -424,7 +424,6 @@ private: void Init() { m_digits = 0; - m_format = wxASCII_STR("%0.0f"); } // Update m_digits and m_format to correspond to the given increment. diff --git a/src/generic/spinctlg.cpp b/src/generic/spinctlg.cpp index 7255045e24..8048e72682 100644 --- a/src/generic/spinctlg.cpp +++ b/src/generic/spinctlg.cpp @@ -778,8 +778,13 @@ void wxSpinCtrlDouble::DetermineDigits(double inc) if ( inc > 0.0 && inc < 1.0 ) { m_digits = wxMin(SPINCTRLDBL_MAX_DIGITS, -static_cast(floor(log10(inc)))); - m_format.Printf("%%0.%ulf", m_digits); } + else + { + m_digits = 0; + } + + m_format.Printf("%%0.%ulf", m_digits); } #endif // wxUSE_SPINBTN