Qt: fix CurrentSelectionIconPath()

This commit is contained in:
Megamouse 2018-01-12 16:58:50 +01:00 committed by Ivan
parent fbde1818a2
commit ef6a36241e

View file

@ -1232,19 +1232,14 @@ std::string game_list_frame::CurrentSelectionIconPath()
{ {
std::string selection = ""; std::string selection = "";
// The index can be more than the size of m_game_data if you use the VFS to load a directory which has less games. if (m_gameList->selectedItems().count())
if (m_oldLayoutIsList && m_gameList->selectedItems().count() && m_gameList->currentRow() < m_game_data.size())
{ {
selection = m_game_data.at(m_gameList->item(m_gameList->currentRow(), 0)->data(Qt::UserRole).toInt()).info.icon_path; QTableWidgetItem* item = m_oldLayoutIsList ? m_gameList->item(m_gameList->currentRow(), 0) : m_xgrid->currentItem();
} int ind = item->data(Qt::UserRole).toInt();
else if (!m_oldLayoutIsList && m_xgrid->selectedItems().count())
{
int ind = m_xgrid->currentItem()->data(Qt::UserRole).toInt();
if (ind < m_game_data.size()) if (ind < m_game_data.size())
{
selection = m_game_data.at(ind).info.icon_path; selection = m_game_data.at(ind).info.icon_path;
} }
}
m_oldLayoutIsList = m_isListLayout; m_oldLayoutIsList = m_isListLayout;