Fix rare crash on Linux when opening dropdowns.

Patch by: @wraitii
Accepted by: @Angen
Fixes #5598
Fixes #6225

Differential Revision: https://code.wildfiregames.com/D4183
This was SVN commit r25830.
This commit is contained in:
Stan
2021-07-20 20:59:45 +00:00
parent 5eec8039b4
commit 72a20be1df
2 changed files with 11 additions and 4 deletions
+4 -1
View File
@@ -169,7 +169,10 @@ void CDropDown::HandleMessage(SGUIMessage& Message)
m_ElementHighlight = m_Selected;
// Start at the position of the selected item, if possible.
GetScrollBar(0).SetPos(m_ItemsYPositions.empty() ? 0 : m_ItemsYPositions[m_ElementHighlight] - 60);
if (m_ItemsYPositions.empty() || m_ElementHighlight < 0 || static_cast<size_t>(m_ElementHighlight) >= m_ItemsYPositions.size())
GetScrollBar(0).SetPos(0);
else
GetScrollBar(0).SetPos(m_ItemsYPositions[m_ElementHighlight] - 60);
PlaySound(m_SoundOpened);
return; // overshadow