Fixes leak of DolphinFileMetaDataWidget in ToolTipManager
ClosedPublic

Authored by hallas on Mar 3 2019, 6:41 AM.

Details

Summary

Fixes leak of DolphinFileMetaDataWidget in ToolTipManager. The
destructor of ToolTipManager failed to delete the m_fileMetaDataWidget
member. This is seen at shutdown but also when you close a tab that has
displayed a tooltip.

Test Plan

Compile Dolphin with address sanitizer
Open Dolphin
Show a tooltip
Close Dolphin

Diff Detail

Repository
R318 Dolphin
Branch
fixes_leak_of_dolphin_file_meta_data_widget (branched from master)
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 9425
Build 9443: arc lint + arc unit
hallas created this revision.Mar 3 2019, 6:41 AM
Restricted Application added a project: Dolphin. · View Herald TranscriptMar 3 2019, 6:41 AM
Restricted Application added a subscriber: kfm-devel. · View Herald Transcript
hallas requested review of this revision.Mar 3 2019, 6:41 AM
elvisangelaccio added inline comments.Mar 9 2019, 5:49 PM
src/views/tooltips/tooltipmanager.cpp
85–87

Why reset() it twice? The second reset() call should be enough

hallas added inline comments.Mar 9 2019, 5:58 PM
src/views/tooltips/tooltipmanager.cpp
85–87

I was just trying to mimic the original behavior. If there is only a single reset then there will be a short period of time where two DolphinFileMetaDataWidget instances are allocated because first the new DolphinFileMetaDataWidget is allocated, then it it passed to the reset function, which deletes the instance it owns and keeps the new one. A standard way of avoiding this is simply to call reset first without any arguments, then the original instance is deleted before the new one is allocated.

But I can change it to a single reset call, what do you think?

elvisangelaccio added inline comments.Mar 9 2019, 6:31 PM
src/views/tooltips/tooltipmanager.cpp
85–87

If there is only a single reset then there will be a short period of time where two DolphinFileMetaDataWidget instances are allocated because first the new DolphinFileMetaDataWidget is allocated, then it it passed to the reset function, which deletes the instance it owns and keeps the new one.

Hmm, this feels like a theoretical problem only. IMHO readability and consistency of code should be preferred (we don't reset a QScopedPointer like this anywhere else in dolphin).

hallas updated this revision to Diff 53535.Mar 9 2019, 7:25 PM

Remove extra release call to keep things consistent.

hallas added inline comments.Mar 9 2019, 7:25 PM
src/views/tooltips/tooltipmanager.cpp
85–87

I have removed the extra reset to keep things consistent :)

elvisangelaccio requested changes to this revision.Mar 9 2019, 9:38 PM
elvisangelaccio added inline comments.
src/views/tooltips/tooltipmanager.cpp
88

QScopedPointer::get() is Qt 5.11+ only, please use QScopedPointer::data() instead.

This revision now requires changes to proceed.Mar 9 2019, 9:38 PM
hallas updated this revision to Diff 53578.Mar 10 2019, 9:01 AM

Change get() to data() to have compatability with pre Qt 5.11

hallas marked an inline comment as done.Mar 10 2019, 9:02 AM
hallas added inline comments.
src/views/tooltips/tooltipmanager.cpp
88

Good catch ;) I have changed this to QScopedPointer::data()

src/views/tooltips/tooltipmanager.cpp
211

What about this one? ;)

hallas updated this revision to Diff 53601.Mar 10 2019, 3:41 PM
hallas marked an inline comment as done.

Change the last QScopedPointer::get call to QScopedPointer::data

hallas added inline comments.Mar 10 2019, 3:41 PM
src/views/tooltips/tooltipmanager.cpp
211

Sorry about that, fixed now ;)

This revision is now accepted and ready to land.Mar 10 2019, 4:27 PM
hallas closed this revision.Mar 10 2019, 4:41 PM