[kiriki] avoid memory leak

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



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

R399 Kiriki
Automatic diff as part of commit; lint not applicable.
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

31 ↗(On Diff #31320)


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.