1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-10-10 16:43:33 +02:00

Fix dangling pointer bug, caused assertion opening Preferences

This commit is contained in:
Paul Licameli
2019-12-01 13:50:36 -05:00
parent ab05cdcdaf
commit 3704336a58
2 changed files with 6 additions and 9 deletions

View File

@@ -1515,11 +1515,8 @@ wxRadioButton * ShuttleGuiBase::TieRadioButton()
wxASSERT( mRadioCount >= 0); // Did you remember to use StartRadioButtonGroup() ?
EnumValueSymbol symbol;
if (mpRadioSetting && mRadioCount >= 0) {
const auto &symbols = mpRadioSetting->GetSymbols();
if ( mRadioCount < symbols.size() )
symbol = symbols[ mRadioCount ];
}
if (mRadioCount >= 0 && mRadioCount < mRadioSymbols.size() )
symbol = mRadioSymbols[ mRadioCount ];
// In what follows, WrappedRef is used in read only mode, but we
// don't have a 'read-only' version, so we copy to deal with the constness.
@@ -1574,7 +1571,7 @@ wxRadioButton * ShuttleGuiBase::TieRadioButton()
/// Call this before any TieRadioButton calls.
void ShuttleGuiBase::StartRadioButtonGroup( const ChoiceSetting &Setting )
{
mpRadioSetting = &Setting;
mRadioSymbols = Setting.GetSymbols();
// Configure the generic type mechanism to use OUR string.
mRadioValueString = Setting.Default().Internal();
@@ -1592,14 +1589,14 @@ void ShuttleGuiBase::StartRadioButtonGroup( const ChoiceSetting &Setting )
void ShuttleGuiBase::EndRadioButtonGroup()
{
// too few buttons?
wxASSERT( mRadioCount == mpRadioSetting->GetSymbols().size() );
wxASSERT( mRadioCount == mRadioSymbols.size() );
if( mShuttleMode == eIsGettingFromDialog )
DoDataShuttle( mRadioSettingName, *mRadioValue );
mRadioValue.reset();// Clear it out...
mRadioSettingName = wxT("");
mRadioCount = -1; // So we detect a problem.
mpRadioSetting = nullptr;
mRadioSymbols = {};
}
//-----------------------------------------------------------------------//

View File

@@ -405,7 +405,7 @@ private:
wxSlider * DoTieSlider( const wxString &Prompt, WrappedType & WrappedRef, const int max, const int min = 0 );
wxSpinCtrl * DoTieSpinCtrl( const wxString &Prompt, WrappedType & WrappedRef, const int max, const int min = 0 );
const ChoiceSetting *mpRadioSetting = nullptr;
std::vector<EnumValueSymbol> mRadioSymbols;
wxString mRadioSettingName; /// The setting controlled by a group.
Maybe<WrappedType> mRadioValue; /// The wrapped value associated with the active radio button.
int mRadioCount; /// The index of this radio item. -1 for none.