Fixes memory leak of KItemListHeader
The KItemListHeader passed the listView parent object to the QObject
base class, but that pointer seems to always be nullptr causing the
KItemListHeader to not be memory managed by anything. Instead simple
use the listView as parent pointer.
Details
- Reviewers
elvisangelaccio - Commits
- R318:d2783df3104d: Fixes memory leak of KItemListHeader
This leak was found using Address Sanitizer
Diff Detail
- Repository
- R318 Dolphin
- Branch
- fixes_leak_of_item_list_header (branched from master)
- Lint
No Linters Available - Unit
No Unit Test Coverage - Build Status
Buildable 8780 Build 8798: arc lint + arc unit
I don't know :) I can just see from Address Sanitizer that the KItemListView was not being freed, and I traced this to the fact that the parent pointer is nullptr. Could this be caused by other code changes previously? So this is essentially a leftover from previous behavior?
Hi @elvisangelaccio - I have been digging a bit more into this, and the reason why the parent is nullptr at this point is because it is setup at a later point. Actually it ends up being set be KItemListController::setView function, but that only happens after the KItemListView (which is the class allocating the KItemListHeader instance) has been constructed. It essentially a Chicken-Egg problem, if you look at the constructor for DolphinView, you can see that the view is constructed before the controller, and it is actually the controller that ends up being the parent for the view. So therefore I still think this is the way to fix this small memory leak.
Thanks for the investigation. Please put this information in the commit message, then push it :)