Minor cleanups of TabSwitcher plugin
ClosedPublic

Authored by dhaumann on Oct 20 2018, 7:31 PM.

Details

Summary

Changes include:

  • fix one memory leak
  • use KTextEditor::Document in model data
  • avoid using QStandardItem, since no standard models are used

This is a follow-up change to 47cf54ddf423f4765b406ebe3e0cb8dcc5ca52a2

Test Plan

manual testing

Diff Detail

Repository
R40 Kate
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
dhaumann created this revision.Oct 20 2018, 7:31 PM
Restricted Application added a project: Kate. · View Herald TranscriptOct 20 2018, 7:31 PM
Restricted Application added a subscriber: kwrite-devel. · View Herald Transcript
dhaumann requested review of this revision.Oct 20 2018, 7:31 PM

In yet another patch, I would change the public members of FilenameListItem to getter functions. Then we are free to either cache the data, or only calculate all stuff on-the-fly from the KTextEditor::Document.

One thing about the memleak. I tried to find it just be running valgrind

valgrind --leak-check=yes kate

I got something like this:

==6196== 2,018 (192 direct, 1,826 indirect) bytes in 4 blocks are definitely lost in loss record 7,067 of 7,126
==6196==    at 0x4C2E04F: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==6196==    by 0x720EF97: ??? (in /usr/lib64/libstdc++.so.6.0.25)
==6196==    by 0x1ED10EA1: ??? (in /home/gregor/kde/usr/lib64/plugins/ktexteditor/tabswitcherplugin.so)
==6196==    by 0x1ED1038A: ??? (in /home/gregor/kde/usr/lib64/plugins/ktexteditor/tabswitcherplugin.so)
==6196==    by 0x1ED100DC: ??? (in /home/gregor/kde/usr/lib64/plugins/ktexteditor/tabswitcherplugin.so)
==6196==    by 0x452322: ??? (in /home/gregor/kde/usr/bin/kate)
==6196==    by 0x451FA9: ??? (in /home/gregor/kde/usr/bin/kate)

I wonder why symbol names and line numbers are missing. I checked if debug_info is present:

$ file /home/gregor/kde/usr/lib64/plugins/ktexteditor/tabswitcherplugin.so
/home/gregor/kde/usr/lib64/plugins/ktexteditor/tabswitcherplugin.so: ELF 64-bit LSB pie executable x86-64, version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=1797b5bed64b6cd245c08c927af421438b646d0c, with debug_info, not stripped

$ file kate
kate: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=0b925b6b1beed50b776eac581b7cb018e99063ae, with debug_info, not stripped

Is there something else I can check to find out why symbols are not found?

I tested kate and tstestapp. Both work fine.

addons/tabswitcher/tests/tstestapp.cpp
23

I wondered why this works despite that fact that the given file does not exist. But apparently, all needed parts of the document instance are filled to be useful in this test.

gregormi accepted this revision.Oct 21 2018, 9:47 AM
This revision is now accepted and ready to land.Oct 21 2018, 9:47 AM
dhaumann marked an inline comment as done.Oct 21 2018, 3:43 PM
dhaumann added inline comments.
addons/tabswitcher/tests/tstestapp.cpp
23

This works, because if a document cannot be loaded, it will save it to disk when we call save(). But we never call save(), so everything is fine.

This revision was automatically updated to reflect the committed changes.
dhaumann marked an inline comment as done.

@gregormi In my ~/kde/kf5/src/kdesrc-buildrc file I have the line:

cmake-options -DKDE4_BUILD_TESTS=TRUE -DLIB_SUFFIX=64 -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=ON

Note the -DCMAKE_BUILD_TYPE=Debug. Do you have something similar? If valgrind does not list details, it's missing.

@gregormi In my ~/kde/kf5/src/kdesrc-buildrc file I have the line:

cmake-options -DKDE4_BUILD_TESTS=TRUE -DLIB_SUFFIX=64 -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=ON

Note the -DCMAKE_BUILD_TYPE=Debug. Do you have something similar? If valgrind does not list details, it's missing.

I have CMAKE_BUILD_TYPE=Debug currently not in kdesrc-buildrc but I set it manually on kate and other project individually. I would expect to get debug info for all libraries which are compiled with debug_infos.