diff options
| author | Salanto <62221668+Salanto@users.noreply.github.com> | 2024-08-03 11:39:29 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-03 11:39:29 +0200 |
| commit | 6a44e09f058cb1211406507df37508fcf1a7e126 (patch) | |
| tree | 0ac93f1dee26f71f9ca0be5fce1756015a650f13 /src/widgets | |
| parent | ac673099e0fdadd46453762d811bc3098408ebc5 (diff) | |
Fix crash in demos due to PU not being recorded (#1032)
Added some guards due to bad demo files being shared by now
Diffstat (limited to 'src/widgets')
| -rw-r--r-- | src/widgets/playerlistwidget.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/widgets/playerlistwidget.cpp b/src/widgets/playerlistwidget.cpp index 2a3a8987..c72b74ae 100644 --- a/src/widgets/playerlistwidget.cpp +++ b/src/widgets/playerlistwidget.cpp @@ -139,6 +139,11 @@ void PlayerListWidget::filterPlayerList() int area_id = m_player_map.value(ao_app->client_id).area_id; for (QListWidgetItem *item : qAsConst(m_item_map)) { + if (!item) + { + qWarning() << "Trying to filter item that does not exist. This indicates either a broken server-implementation or a bad demo file."; + break; + } item->setHidden(m_player_map[item->data(Qt::UserRole).toInt()].area_id != area_id); } } @@ -147,6 +152,13 @@ void PlayerListWidget::updatePlayer(int playerId, bool updateIcon) { PlayerData &data = m_player_map[playerId]; QListWidgetItem *item = m_item_map[playerId]; + + if (!item) + { + qWarning() << "No player at ID" << playerId << ". This might indicate a broker server implementation or a bad demo file."; + return; + } + item->setText(data.name.isEmpty() ? QObject::tr("Unnamed Player") : data.name); if (data.character.isEmpty()) { |
