Skip to content

Commit

Permalink
Avoid compiler warning about dangling reference
Browse files Browse the repository at this point in the history
This addresses the following warning:

    warning: possibly dangling reference to a temporary [-Wdangling-reference]
      777 |         const Chunk &chunk = it.next().value();
          |                      ^~~~~

It's a false positive, since even though the temporary was destroyed,
the returned Chunk reference will remain valid...
  • Loading branch information
bjorn committed Jun 28, 2023
1 parent 3141a39 commit cab3ea3
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/libtiled/tilelayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,8 @@ QVector<QRect> TileLayer::sortedChunksToWrite(QSize chunkSize) const

QHashIterator<QPoint, Chunk> it(mChunks);
while (it.hasNext()) {
const Chunk &chunk = it.next().value();
it.next();
const Chunk &chunk = it.value();
if (chunk.isEmpty())
continue;

Expand Down

0 comments on commit cab3ea3

Please sign in to comment.