Commit 1d2ae0cc authored by Julian Helfferich's avatar Julian Helfferich 💬
Browse files

Fix the test and fix the crash

To fix the issue, I introduced a test whether the game logic object has
created single games (by trying to access one). Only if the game logic
object has single games, stop game and delete single games is called.

I have also confirmed by manual testing that the game no longer crashes
when (re)starting a game after the first one.

The test is not as unit-test-y as I would like: Several QWARN are
issued. Furthermore, there is another option to improve usability:

The last piece is also placed ontop of an existing piece, triggering a
game over. However, this final piece is still invisible.
parent a3e9b5fe
......@@ -15,3 +15,10 @@ ecm_add_test(
LINK_LIBRARIES Qt5::Test KBlocksCore
NAME_PREFIX "UnitTest-"
)
ecm_add_test(
test_KBlocksWin.cpp
TEST_NAME KBlocksWin
LINK_LIBRARIES Qt5::Test KBlocksCore
NAME_PREFIX "UnitTest-"
)
......@@ -140,9 +140,11 @@ void KBlocksWin::startGame()
void KBlocksWin::stopGame()
{
if (mpGameLogic->deleteSingleGames()) {
// Clear the game field
if (mpGameLogic->getSingleGame(0)) {
// If singleGame(s) exist
mpGameScene->stopGame();
mpGameLogic->deleteSingleGames();
// Clear the game field
mpGameScene->deleteGameItemGroups();
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment