KadeModeMenuList: fix memory leaks and others
ClosedPublic

Authored by nibags on Sep 25 2019, 7:16 AM.

Details

Summary
  • Remove strings m_searchName in the destructor of the ListItem class.
  • Use the same object for transparent colors/icons.
  • Add the Deselect flag in item sections.

Diff Detail

Repository
R39 KTextEditor
Branch
fix-mode-menu
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 17036
Build 17054: arc lint + arc unit
nibags created this revision.Sep 25 2019, 7:16 AM
Restricted Application added projects: Kate, Frameworks. · View Herald TranscriptSep 25 2019, 7:16 AM
Restricted Application added subscribers: kde-frameworks-devel, kwrite-devel. · View Herald Transcript
nibags requested review of this revision.Sep 25 2019, 7:16 AM

I must confess the m_searchName deletion condition seems for me too be overly complex.
Given QString copying is cheap, can't we just always set that and store it inline as value?

nibags updated this revision to Diff 66864.Sep 26 2019, 5:10 AM
  • Update
  • Add boolean m_bHasNewSearchName to verify removal of m_searchName.
  • Correct format in some comments.
  • Remove friend KateModeMenuList and replace it with the "Factory" class.

m_searchName is a pointer to an attribute of a KateFileType object (which may be the string translatedName or name), but in some cases a new string is created.

I added the boolean m_bHasNewSearchName that is true when a new QString is created for search. This is much simpler.

Still, if you don't like it and prefer to use inline attributes, I can change it without problems =)

I would prefer just some QString m_searchName, strings are shared anyways, no need to try to save there a few bytes but then introduce more heap allocated things.

cullmann requested changes to this revision.Sep 28 2019, 6:14 PM
This revision now requires changes to proceed.Sep 28 2019, 6:14 PM
nibags updated this revision to Diff 67026.Sep 29 2019, 11:33 AM
  • Fix allocation in search names
cullmann accepted this revision.Sep 29 2019, 11:40 AM

Like that better, thanks!

This revision is now accepted and ready to land.Sep 29 2019, 11:40 AM
This revision was automatically updated to reflect the committed changes.