Port KFind away from KDialog
ClosedPublic

Authored by yurchor on Oct 6 2018, 7:07 PM.

Details

Summary

Trying to port from the deprecated KDialog to make KFind pure KF5 application.

Test Plan
  1. Should be compilable without warnings on KDialog deprecation.
  2. Visually indistinguishable from the unported version (resizing of the window works just the same even without hints).
  3. Crashes after pushing the "Search" button. For some reason, it is impossible for my code to change the enable state of the buttons.

Can somebody give a hint on where did I go wrong? Thanks in advance.

Diff Detail

Repository
R228 KFind
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
yurchor requested review of this revision.Oct 6 2018, 7:07 PM
yurchor created this revision.
broulik requested changes to this revision.Oct 8 2018, 12:51 PM
broulik added a subscriber: broulik.

The order of the top right buttons is also reversed now, "Search" is the bottom-most button in the section now.

src/kfinddlg.cpp
32

Put Qt includes with the other ones above and sort alphabetically (only the ones you add, don't change the surrounding code :)

75

Coding style: put spaces around |

76

The crash is because you create a local variable and as such the member variable in the class is never assigned and calling it in e.g. startSearch crashes as it accesses uninitialized memory. That's why we typically prefix member variables with m_, which isn't the case in this old legacy code.
Just do

user1Button = foo;

Also, QDialogButtonBox::addButton(QPushButton*) takes ownership, so the this parent isn't required

97

While at it, use new connect syntax

src/kfinddlg.h
76

I would prefer if you gave them proper names, like searchButton etc.
Also prefix them with m_ to avoid the crash I explain further down

This revision now requires changes to proceed.Oct 8 2018, 12:51 PM
yurchor updated this revision to Diff 43131.Oct 8 2018, 1:41 PM
  • The includes are sorted now.
  • The buttons renamed using "m_<name>Button" syntax.
  • Spaces are added around the |.
  • Declaration of the buttons rewritten to avoid the crash.
  • The new syntax is used to connect signals and slots.
yurchor marked 5 inline comments as done.Oct 8 2018, 1:43 PM
broulik accepted this revision.Oct 8 2018, 2:16 PM

Thanks!

This revision is now accepted and ready to land.Oct 8 2018, 2:16 PM
This revision was automatically updated to reflect the committed changes.

One thing I noticed after this change is that the "Name" text field doesn't get automatically focused as I open KFind. Can you perhaps investigate this? :)

One thing I noticed after this change is that the "Name" text field doesn't get automatically focused as I open KFind. Can you perhaps investigate this? :)

Sure. I will try to fix this.

One thing I noticed after this change is that the "Name" text field doesn't get automatically focused as I open KFind. Can you perhaps investigate this? :)

Sure. I will try to fix this.

Should be fixed now.