Commit 546a8ca3 authored by Julian Helfferich's avatar Julian Helfferich 💬
Browse files

Fix memory leak in KBlocksScene

The destructor of KBlocksScene now calls deleteGameItemGroups() to
ensure that the created objects are properly delete. This fixes a
memory leak flagged by valgrind.
parent 5256838e
Pipeline #50976 passed with stage
in 4 minutes and 1 second
......@@ -61,6 +61,7 @@ KBlocksScene::KBlocksScene(
KBlocksScene::~KBlocksScene()
{
deleteGameItemGroups();
delete [] maGameReadySignal;
delete [] maGameScoreList;
delete [] maGroupList;
......@@ -110,8 +111,10 @@ void KBlocksScene::createGameItemGroups(int groupCount, bool snapshotMode)
void KBlocksScene::deleteGameItemGroups()
{
removeItem(mMessageBox);
delete mMessageBox;
if (mMessageBox) {
removeItem(mMessageBox);
delete mMessageBox;
}
for (int i = 0; i < mGroupCount; i++) {
disconnect(maGroupList[i], &KBlocksItemGroup::readyForAction, this, &KBlocksScene::readyForAction);
......
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