Skip to content
Browse files

Clear out a setting control when they're removed

  • Loading branch information...
1 parent aad9c2b commit 28406a26eb1fec99a60c2aa272ede308882850bd Jonathan Marshall committed Dec 19, 2012
View
4 xbmc/settings/GUIWindowSettingsCategory.cpp
@@ -2039,10 +2039,12 @@ void CGUIWindowSettingsCategory::FreeSettingsControls()
control->ClearAll();
}
- for(int i = 0; (size_t)i < m_vecSettings.size(); i++)
+ for (int i = 0; (size_t)i < m_vecSettings.size(); i++)
{
+ m_vecSettings[i]->Clear();
delete m_vecSettings[i];
}
+
m_vecSettings.clear();
}
View
10 xbmc/settings/SettingsControls.cpp
@@ -55,7 +55,8 @@ bool CRadioButtonSettingControl::OnClick()
void CRadioButtonSettingControl::Update()
{
- m_pRadioButton->SetSelected(((CSettingBool *)m_pSetting)->GetData());
+ if (m_pRadioButton)
+ m_pRadioButton->SetSelected(((CSettingBool *)m_pSetting)->GetData());
}
CSpinExSettingControl::CSpinExSettingControl(CGUISpinControlEx *pSpin, int id, CSetting *pSetting)
@@ -125,6 +126,8 @@ bool CSpinExSettingControl::OnClick()
void CSpinExSettingControl::Update()
{
+ if (!m_pSpin)
+ return;
if (m_pSetting->GetControlType() == SPIN_CONTROL_FLOAT)
{
CSettingFloat *pSettingFloat = (CSettingFloat *)m_pSetting;
@@ -174,7 +177,8 @@ void CButtonSettingControl::Update()
}
else if (m_pSetting->GetControlType() == BUTTON_CONTROL_STANDARD)
return;
- m_pButton->SetLabel2(strText);
+ if (m_pButton)
+ m_pButton->SetLabel2(strText);
}
CEditSettingControl::CEditSettingControl(CGUIEditControl *pEdit, int id, CSetting *pSetting)
@@ -215,7 +219,7 @@ bool CEditSettingControl::OnClick()
void CEditSettingControl::Update()
{
- if (!m_needsUpdate)
+ if (!m_needsUpdate && m_pEdit)
m_pEdit->SetLabel2(((CSettingString *)m_pSetting)->GetData());
}
View
6 xbmc/settings/SettingsControls.h
@@ -40,6 +40,7 @@ class CBaseSettingControl
CSetting* GetSetting() { return m_pSetting; };
virtual bool NeedsUpdate() { return false; }; ///< Returns true if the control needs an update
virtual void Reset() {}; ///< Resets the NeedsUpdate() state
+ virtual void Clear()=0; ///< Clears the attached control
/*!
\brief Specifies that this setting should update after a delay
@@ -70,6 +71,7 @@ class CRadioButtonSettingControl : public CBaseSettingControl
virtual ~CRadioButtonSettingControl();
virtual bool OnClick();
virtual void Update();
+ virtual void Clear() { m_pRadioButton = NULL; }
void Select(bool bSelect);
private:
CGUIRadioButtonControl *m_pRadioButton;
@@ -82,6 +84,7 @@ class CSpinExSettingControl : public CBaseSettingControl
virtual ~CSpinExSettingControl();
virtual bool OnClick();
virtual void Update();
+ virtual void Clear() { m_pSpin = NULL; }
private:
CGUISpinControlEx *m_pSpin;
};
@@ -93,6 +96,7 @@ class CButtonSettingControl : public CBaseSettingControl
virtual ~CButtonSettingControl();
virtual bool OnClick();
virtual void Update();
+ virtual void Clear() { m_pButton = NULL; }
private:
CGUIButtonControl *m_pButton;
};
@@ -106,6 +110,7 @@ class CEditSettingControl : public CBaseSettingControl
virtual void Update();
virtual bool NeedsUpdate() { return m_needsUpdate; };
virtual void Reset() { m_needsUpdate = false; };
+ virtual void Clear() { m_pEdit = NULL; }
private:
bool IsValidIPAddress(const CStdString &strIP);
CGUIEditControl *m_pEdit;
@@ -119,6 +124,7 @@ class CSeparatorSettingControl : public CBaseSettingControl
virtual ~CSeparatorSettingControl();
virtual bool OnClick() { return false; };
virtual void Update() {};
+ virtual void Clear() { m_pImage = NULL; }
private:
CGUIImage *m_pImage;
};

0 comments on commit 28406a2

Please sign in to comment.
Something went wrong with that request. Please try again.