Replace obsolete QSignalMapper and qSort with non-obsolete code
ClosedPublic

Authored by yurchor on Aug 3 2019, 4:58 PM.

Details

Summary

qSort and QSignalMapper are deprecated and spoil the compilation messages with warnings:

https://build.kde.org/job/Applications/job/ktouch/job/kf5-qt5%20FreeBSDQt5.13/10/warnings12Result/

This patch tries to get rid of these warnings.

Test Plan
  1. Compile (there should be no warnings with Qt 5.13).
  2. Run KTouch, open the course and layout editor and create a course. The new item should be correctly added to the lists in the Editor and the main KTouch window. Delete the course.
  3. Add a layout. Add a key. Resize the key. KTouch should behave as expected. Remove the layout.

Diff Detail

Repository
R336 KTouch
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
yurchor created this revision.Aug 3 2019, 4:58 PM
Restricted Application added a project: KDE Edu. · View Herald TranscriptAug 3 2019, 4:58 PM
Restricted Application added a subscriber: kde-edu. · View Herald Transcript
yurchor requested review of this revision.Aug 3 2019, 4:58 PM
gottfried requested changes to this revision.Aug 5 2019, 8:29 AM

Looks mostly good and works as intended. But its seems you have missed the member declarations and include directives:

ktouch/src$ grep -r "QSignalMapper"
models/lessonmodel.cpp:#include <QSignalMapper>
models/charactersmodel.h:class QSignalMapper;
models/charactersmodel.h:    QSignalMapper* m_signalMapper;
models/resourcemodel.h:class QSignalMapper;
models/resourcemodel.h:    QSignalMapper* m_signalMapper;
models/resourcemodel.cpp:#include <QSignalMapper>
models/charactersmodel.cpp:#include <QSignalMapper>
models/lessonmodel.h:class QSignalMapper;
models/lessonmodel.h:    QSignalMapper* m_signalMapper;
core/course.cpp:#include <QSignalMapper>
core/keyboardlayout.h:class QSignalMapper;
core/keyboardlayout.h:    QSignalMapper* m_signalMapper;
core/course.h:class QSignalMapper;
core/course.h:    QSignalMapper* m_signalMapper;
core/keyboardlayout.cpp:#include <QSignalMapper>

Can you please remove these?

src/models/lessonmodel.cpp
150–155

updateMappings is called multiple times. If I am not mistaken, this will result in multiple connections to the lambda with different values of ì of you don't disconnect() first.

This revision now requires changes to proceed.Aug 5 2019, 8:29 AM
yurchor updated this revision to Diff 63101.Aug 5 2019, 9:12 AM

Remove QSignalMapper leftovers, disconnect signals before connecting them again.

I found two more spots which leak connections over time. These should be fixed.

src/models/resourcemodel.cpp
248–257

We need to disconnect here first, too.

262–269

We need to disconnect here first, too.

yurchor updated this revision to Diff 63157.Aug 6 2019, 7:03 AM

Disconnect stale connections first in resourcemodel.cpp

yurchor marked 3 inline comments as done.Aug 6 2019, 7:04 AM
gottfried accepted this revision.Aug 7 2019, 6:30 AM

Sorry for the long wait. I discovered a crash in the keyboard layout editor which I suspected to be related to you work, but it is not. Still, I wanted to figure this out first.

This revision is now accepted and ready to land.Aug 7 2019, 6:30 AM
This revision was automatically updated to reflect the committed changes.