mirror of
https://github.com/stenzek/duckstation.git
synced 2025-06-07 03:55:33 +00:00
Qt: Fix possible crash when rescanning game list
This commit is contained in:
parent
3e8ef44a1d
commit
0428a93315
@ -637,6 +637,11 @@ QVariant GameListModel::headerData(int section, Qt::Orientation orientation, int
|
||||
return m_column_display_names[section];
|
||||
}
|
||||
|
||||
const GameList::Entry* GameListModel::getTakenGameListEntry(u32 index) const
|
||||
{
|
||||
return (m_taken_entries.has_value() && index < m_taken_entries->size()) ? &m_taken_entries.value()[index] : nullptr;
|
||||
}
|
||||
|
||||
bool GameListModel::hasTakenGameList() const
|
||||
{
|
||||
return m_taken_entries.has_value();
|
||||
|
@ -62,6 +62,7 @@ public:
|
||||
ALWAYS_INLINE const QPixmap& getHasAchievementsPixmap() const { return m_has_achievements_pixmap; }
|
||||
ALWAYS_INLINE const QPixmap& getMasteredAchievementsPixmap() const { return m_mastered_achievements_pixmap; }
|
||||
|
||||
const GameList::Entry* getTakenGameListEntry(u32 index) const;
|
||||
bool hasTakenGameList() const;
|
||||
void takeGameList();
|
||||
|
||||
|
@ -69,7 +69,11 @@ public:
|
||||
bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const override
|
||||
{
|
||||
const auto lock = GameList::GetLock();
|
||||
const GameList::Entry* entry = GameList::GetEntryByIndex(source_row);
|
||||
const GameList::Entry* entry = m_model->hasTakenGameList() ?
|
||||
m_model->getTakenGameListEntry(static_cast<u32>(source_row)) :
|
||||
GameList::GetEntryByIndex(static_cast<u32>(source_row));
|
||||
if (!entry)
|
||||
return false;
|
||||
|
||||
if (m_merge_disc_sets)
|
||||
{
|
||||
@ -147,10 +151,8 @@ public:
|
||||
u32 num_unlocked_hardcore = 0;
|
||||
bool mastered = false;
|
||||
|
||||
{
|
||||
const QModelIndex source_index = m_sort_model->mapToSource(index);
|
||||
const auto lock = GameList::GetLock();
|
||||
const GameList::Entry* entry = GameList::GetEntryByIndex(static_cast<u32>(source_index.row()));
|
||||
const auto get_data_from_entry = [&num_achievements, &num_unlocked, &num_unlocked_hardcore,
|
||||
&mastered](const GameList::Entry* entry) {
|
||||
if (!entry)
|
||||
return;
|
||||
|
||||
@ -158,6 +160,17 @@ public:
|
||||
num_unlocked = entry->unlocked_achievements;
|
||||
num_unlocked_hardcore = entry->unlocked_achievements_hc;
|
||||
mastered = entry->AreAchievementsMastered();
|
||||
};
|
||||
|
||||
const QModelIndex source_index = m_sort_model->mapToSource(index);
|
||||
if (m_model->hasTakenGameList()) [[unlikely]]
|
||||
{
|
||||
get_data_from_entry(m_model->getTakenGameListEntry(static_cast<u32>(source_index.row())));
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto lock = GameList::GetLock();
|
||||
get_data_from_entry(GameList::GetEntryByIndex(static_cast<u32>(source_index.row())));
|
||||
}
|
||||
|
||||
QRect r = option.rect;
|
||||
|
Loading…
x
Reference in New Issue
Block a user