Fixed crash in kart selection screen that happens if an

addon tab was selected previously, then that group is removed
(by deinstalling its contents with the addon manager). The gui
code tried then to access the previously selected tab, which
doesn't exist anymore. Now it will fall back to use the
first element (which at this stage is sure to exist).


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@8316 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk
2011-04-12 23:18:57 +00:00
parent 9f2cc716eb
commit ec6b6431ac

View File

@@ -513,7 +513,13 @@ const std::string& RibbonWidget::getSelectionIDString(const int playerID)
static std::string empty;
if (m_selection[playerID] == -1) return empty;
if (m_children.size() == 0) return empty;
// This can happen if an addon is removed, which causes a tab group
// to be removed. If this tab group was previously selected, an
// invalid array element would be accessed. In this case just pretend
// that the first child was selected previously.
if(m_selection[playerID]>=m_children.size())
return m_children[0].m_properties[PROP_ID];
return m_children[m_selection[playerID]].m_properties[PROP_ID];
}