Skip to content

Commit

Permalink
Cleanup after deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
Salanto committed Jan 18, 2024
1 parent ce7e050 commit 41b2e30
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/widgets/player_presence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ void PlayerMenu::removePlayer(int f_id)
return;
}
delete f_player;
players.remove(f_id);
}

void PlayerMenu::resetList()
Expand Down

3 comments on commit 41b2e30

@Ganty1999
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PlayerItem *f_player = players.value(f_id);

it will better just players.take(f_id) instead so your doesn't needed to players.remove(f_id)

@Salanto
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch, didn't know QMap has a take function too. The more you know.

@Ganty1999
Copy link

@Ganty1999 Ganty1999 commented on 41b2e30 Jan 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch, didn't know QMap has a take function too. The more you know.

well.. QMap is same like QVector but in difference way.
also, your might want to fixing the code:

QString label;
  if (m_isSpecial) {
    label = label + "⭐";
  }
  label = label + QString("[%1]%2").arg(QString::number(m_id), m_name);

to this instead:

QString label = QString("[%1]%2").arg(QString::number(m_id), m_name);
  if (m_isSpecial)
      label.append("⭐");

(edited)

Please sign in to comment.