Qt: add mutex to game list creation

should prevent random crashes when accessing maps
This commit is contained in:
Megamouse 2019-10-25 10:26:07 +02:00
parent 63a0b97dd1
commit 89a2d04f96

View file

@ -449,6 +449,8 @@ void game_list_frame::Refresh(const bool fromDrive, const bool scrollAfter)
QSet<QString> serials;
QMutex mutex_cat;
QList<size_t> indices;
for (size_t i = 0; i < path_list.size(); ++i)
indices.append(i);
@ -482,9 +484,12 @@ void game_list_frame::Refresh(const bool fromDrive, const bool scrollAfter)
game.bootable = psf::get_integer(psf, "BOOTABLE", 0);
game.attr = psf::get_integer(psf, "ATTRIBUTE", 0);
mutex_cat.lock();
// Detect duplication
if (!serial_cat_name[game.serial].emplace(game.category + game.name).second)
{
mutex_cat.unlock();
return;
}
@ -514,6 +519,8 @@ void game_list_frame::Refresh(const bool fromDrive, const bool scrollAfter)
game.category = sstr(category::other);
}
mutex_cat.unlock();
// Load ICON0.PNG
QPixmap icon;