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,18 +1232,13 @@ std::string game_list_frame::CurrentSelectionIconPath()
{
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_oldLayoutIsList && m_gameList->selectedItems().count() && m_gameList->currentRow() < m_game_data.size())
if (m_gameList->selectedItems().count())
{
selection = m_game_data.at(m_gameList->item(m_gameList->currentRow(), 0)->data(Qt::UserRole).toInt()).info.icon_path;
}
else if (!m_oldLayoutIsList && m_xgrid->selectedItems().count())
{
int ind = m_xgrid->currentItem()->data(Qt::UserRole).toInt();
QTableWidgetItem* item = m_oldLayoutIsList ? m_gameList->item(m_gameList->currentRow(), 0) : m_xgrid->currentItem();
int ind = item->data(Qt::UserRole).toInt();
if (ind < m_game_data.size())
{
selection = m_game_data.at(ind).info.icon_path;
}
}
m_oldLayoutIsList = m_isListLayout;