Album memory leak: new score objects created in loadScores() but never deleted

• Sep 21, 2015 - 05:36
Type
Functional
Severity
S4 - Minor
Status
closed
Project

both Album::print() and Album::createScore() create new Score objects when calling Album::loadScores(), but never delete these created score objects.

I'm going to add a new function Album::deleteScores() unloadScores() which iterates over each AlbumItem and deletes the score object if it exists (which will call ~Scores()). Will need to call deleteScores() unloadScores() before every return in print() and createScore(). (EDIT: I think "unloadScores()" might be a little better of a name, because unfortunately both Album and AlbumItem classes contain an element with "score" in the name...also issues with "delete score" might sound like is deleting a score file...and also avoids other confusion with other Album:: function names...)

Not a major issue, unless running mscore continuously (e.g. server mode) and saving/printing tons of albums.

Note the implicit deconstructor for Album will call the deconstor for QList, which will delete each AlbumItem, but the implicit deconstor for AlbumItem itself will not delete the memory pointed to by Score* score.


Comments

(unrelated question: shouldn't album.cpp and album.h be moved inside /libmscore instead of /mscore directory, since album class deals with non-gui related aspects? Of course, albummanager class is appropriately part of the non-library mscore.)