Address some issues reported by Krazy analysis
AcceptedPublic

Authored by pajamapants3000 on Jun 19 2019, 12:47 PM.

Details

Reviewers
elvisangelaccio
Summary

Resolved all issues discovered by the krazy plugins: crashy, explicit.

Other issues remain; I left them alone because I either wasn't sure
they should be addressed or I wasn't sure how to do so.

Test Plan

Should build and pass existing tests - confirmed.

Diff Detail

Repository
R310 KTextWidgets
Branch
krazy-50b2564 (branched from master)
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 12964
Build 12982: arc lint + arc unit
Restricted Application added a project: Frameworks. · View Herald TranscriptJun 19 2019, 12:47 PM
Restricted Application added a subscriber: kde-frameworks-devel. · View Herald Transcript
pajamapants3000 requested review of this revision.Jun 19 2019, 12:47 PM
elvisangelaccio requested changes to this revision.Aug 25 2019, 3:14 PM
elvisangelaccio added a subscriber: elvisangelaccio.
elvisangelaccio added inline comments.
src/widgets/krichtextwidget.cpp
638

This should be linkDialog && linkDialog->exec()

src/widgets/ktextedit.cpp
369

Same here, we need to check the pointer before using it.

This revision now requires changes to proceed.Aug 25 2019, 3:14 PM
vkrause added inline comments.
src/widgets/krichtextwidget.cpp
638

This is unusual, but it's the right way around. The point of this is to check if the dialog has been deleted during the sub-eventloop behind exec(). No idea if that can happen here though, but that's generally the idea behind this pattern.

elvisangelaccio accepted this revision.Aug 25 2019, 3:54 PM
elvisangelaccio added inline comments.
src/widgets/krichtextwidget.cpp
638

Ah of course. I didn't notice it was exec() that was being called.

This revision is now accepted and ready to land.Aug 25 2019, 3:54 PM

Thank you for the feedback and approval! I don't have the access needed to land a change, what should I do next? I would certainly appreciate someone else landing it for me. Let me know, thanks!

broulik added inline comments.
src/widgets/ktextedit.cpp
373

You can do dialog->setAttribute(Qt::WA_DeleteOnClose); when creating the dialog instead of an explicit delete call

src/widgets/krichtextwidget.cpp
638

Coming back after two months, even I thought this looked wrong at first. I will endeavor to make my intent clearer, thank you :)

src/widgets/ktextedit.cpp
373

Thank you broulik! Could we use a QScopedPointer here? I see them throughout the KDE source, but not often for dialogs. The krazy analysis looked for QPointer, referencing blog https://blogs.kde.org/node/3919, which appears to have predated the existence of QScopedPointer.

src/widgets/ktextedit.cpp
373

While we are at it, the best way to fix this would be to not use exec() at all, but use open() instead: https://wiki.qt.io/New_Signal_Slot_Syntax#Asynchronous_made_easier