[kiriki] avoid memory leak
ClosedPublic

Authored by jtamate on Apr 4 2018, 7:18 PM.

Details

Summary

Set again the parent so it is deleted automatically.
avoid this memory leak:
Indirect leak of 72 byte(s) in 1 object(s) allocated from:

#0 0x7f39cec39c70 in operator new(unsigned long) (/usr/lib64/libasan.so.4+0xddc70)
#1 0x4160ed in QList<player>::node_construct(QList<player>::Node*, player const&) /usr/include/qt5/QtCore/qlist.h:435
#2 0x4160ed in QList<player>::append(player const&) /usr/include/qt5/QtCore/qlist.h:584
#3 0x4160ed in scores::scores() /g/5kde/kde/kdegames/kiriki/src/scores.cpp:57
Test Plan

play a new game.

Diff Detail

Repository
R399 Kiriki
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
jtamate requested review of this revision.Apr 4 2018, 7:18 PM
jtamate created this revision.

Not sure if it's possible here bit might it be feasible to extent the scores class' c-tor and hang the object into the parent memory management hierarchy?

And why is m_scores not an object? No need for a pointer here I guess

src/kiriki.h
31 ↗(On Diff #31320)

indentation

jtamate updated this revision to Diff 31327.Apr 4 2018, 8:41 PM
jtamate edited the summary of this revision. (Show Details)

Using @schwarzer proposal.

aacid accepted this revision.Apr 4 2018, 9:23 PM
aacid added a subscriber: aacid.

I think i personally would have preferred the version with the destructor, but not that it matters much, this is also fine.

To put things in perspective this is one of those "technical" leaks, the object lives all the time until the end of the app, but anyway it's good to have clean leak logs :)

This revision is now accepted and ready to land.Apr 4 2018, 9:23 PM
This revision was automatically updated to reflect the committed changes.