1
0
mirror of https://github.com/cookiengineer/audacity synced 2026-02-16 07:47:58 +01:00

Define ChoiceSetting::ReadWithDefault ...

... because some calls might not have used the same defaults as in the Tie...
functions
This commit is contained in:
Paul Licameli
2019-04-04 11:48:10 -04:00
parent bc08f571dc
commit 85b06fe6d0
2 changed files with 34 additions and 1 deletions

View File

@@ -287,6 +287,11 @@ const EnumValueSymbol &ChoiceSetting::Default() const
wxString ChoiceSetting::Read() const
{
const auto &defaultValue = Default().Internal();
return ReadWithDefault( defaultValue );
}
wxString ChoiceSetting::ReadWithDefault( const wxString &defaultValue ) const
{
wxString value;
if ( !gPrefs->Read(mKey, &value, defaultValue) )
if (!mMigrated) {
@@ -356,10 +361,26 @@ void ChoiceSetting::SetDefault( long value )
int EnumSetting::ReadInt() const
{
auto index = Find( Read() );
wxASSERT( index < mIntValues.size() );
return mIntValues[ index ];
}
int EnumSetting::ReadIntWithDefault( int defaultValue ) const
{
wxString defaultString;
auto index0 = FindInt( defaultValue );
if ( index0 < mSymbols.size() )
defaultString = mSymbols[ index0 ].Internal();
else
wxASSERT( false );
auto index = Find( ReadWithDefault( defaultString ) );
wxASSERT( index < mSymbols.size() );
return mIntValues[ index ];
}
size_t EnumSetting::FindInt( int code ) const
{
const auto start = mIntValues.begin();