<table><tr><td style="">yuyichao created this revision.<br />yuyichao added reviewers: mlaurent, yurchor.<br />Herald added a reviewer: KDE Games.<br />Herald added a subscriber: kde-games-devel.<br />yuyichao requested review of this revision.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D27716">View Revision</a></tr></table><br /><div><strong>REVISION SUMMARY</strong><div><p>When a flag is misplaced, a middle click could cause the game to lost.<br />
Currently, if the user choose to restart the game in this case, there is a high chance<br />
that a few pieces around the one middle clicked are revealed right after the game restarted.</p>
<p>The reason is that when the user restart the game in such case,<br />
it happens within <tt style="background: #ebebeb; font-size: 13px;">checkLost</tt>/<tt style="background: #ebebeb; font-size: 13px;">onItemRevealed</tt> which means that the<br />
game might not be the same one anymore after <tt style="background: #ebebeb; font-size: 13px;">onItemRevealed</tt> returns<br />
and the loop handling all neighboring pieces are now operating on the now restarted game.</p>
<p>The fix is to make sure the loop stops when the game is finished. Checking <tt style="background: #ebebeb; font-size: 13px;">m_gameOver</tt> is<br />
unreliable and won't work in this case since the restart of the game would have restarted it.<br />
Instead, the finished status is returned from all functions that triggers such a condition<br />
and the information is propagated back to the caller to terminate the loop appropriately.<br />
This also improved another unreliable use of <tt style="background: #ebebeb; font-size: 13px;">m_gameOver</tt> that is currently harmless.</p>
<p>Debugging was possible thanks to <tt style="background: #ebebeb; font-size: 13px;">rr</tt>.</p></div></div><br /><div><strong>REPOSITORY</strong><div><div>R404 KMines</div></div></div><br /><div><strong>BRANCH</strong><div><div>master</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D27716">https://phabricator.kde.org/D27716</a></div></div><br /><div><strong>AFFECTED FILES</strong><div><div>minefielditem.cpp<br />
minefielditem.h</div></div></div><br /><div><strong>To: </strong>yuyichao, mlaurent, yurchor, KDE Games<br /><strong>Cc: </strong>kde-games-devel<br /></div>