Unverified Commit 45d7ed4e authored byBrowse files
Fix accidental revealing of items when the game is restarted after lost from a middle click.
Summary: When a flag is misplaced, a middle click could cause the game to lost. Currently, if the user choose to restart the game in this case, there is a high chance that a few pieces around the one middle clicked are revealed right after the game restarted. The reason is that when the user restart the game in such case, it happens within `checkLost`/`onItemRevealed` which means that the game might not be the same one anymore after `onItemRevealed` returns and the loop handling all neighboring pieces are now operating on the now restarted game. The fix is to make sure the loop stops when the game is finished. Checking `m_gameOver` is unreliable and won't work in this case since the restart of the game would have reset it. Instead, the finished status is returned from all functions that trigger such a condition and the information is propagated back to the caller to terminate the loop appropriately. This also improved another unreliable use of `m_gameOver` that is currently harmless. Debugging was possible thanks to `rr`. Reviewers: mlaurent, yurchor, #kde_games, aacid Reviewed By: yurchor, aacid Subscribers: aacid, kde-games-devel Differential Revision: https://phabricator.kde.org/D27716
Showing with 29 additions and 18 deletions