Don't manipulate live list

Took 11 minutes
This commit is contained in:
Lukas Brübach 2026-08-14 09:52:26 +02:00
parent d458ef7efa
commit cb8fe8305e

View file

@ -459,8 +459,14 @@ void GameScene::resizeColumnsAndPlayers(const QList<qreal> &minWidthByColumn, qr
qreal extraWidthPerColumn = (newWidth - minWidth) / playersByColumn.size(); qreal extraWidthPerColumn = (newWidth - minWidth) / playersByColumn.size();
qreal newx = phasesToolbar->getWidth(); qreal newx = phasesToolbar->getWidth();
for (int col = 0; col < playersByColumn.size(); ++col) { // Snapshot the columns: resizing a player's table can synchronously trigger
for (PlayerGraphicsItem *player : playersByColumn[col]) { // GameScene::rearrange (table width -> sizeChanged -> updateBoundingRect ->
// sizeChanged -> rearrange), and rearrange rebuilds playersByColumn. Iterating
// the live container across that re-entrant call would use invalidated iterators.
const QList<QList<PlayerGraphicsItem *>> columns = playersByColumn;
for (int col = 0; col < columns.size(); ++col) {
for (PlayerGraphicsItem *player : columns[col]) {
player->processSceneSizeChange(minWidthByColumn[col] + extraWidthPerColumn); player->processSceneSizeChange(minWidthByColumn[col] + extraWidthPerColumn);
player->setPos(newx, player->y()); player->setPos(newx, player->y());
} }