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.
This commit is contained in:
Vadim Zeitlin
2021-04-25 19:13:22 +01:00
parent e748c2b56c
commit e2d2b367af
2 changed files with 6 additions and 2 deletions

View File

@@ -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.

View File

@@ -778,8 +778,13 @@ void wxSpinCtrlDouble::DetermineDigits(double inc)
if ( inc > 0.0 && inc < 1.0 )
{
m_digits = wxMin(SPINCTRLDBL_MAX_DIGITS, -static_cast<int>(floor(log10(inc))));
m_format.Printf("%%0.%ulf", m_digits);
}
else
{
m_digits = 0;
}
m_format.Printf("%%0.%ulf", m_digits);
}
#endif // wxUSE_SPINBTN