Fix clazy 'connect-3arg-lambda' warnings
ClosedPublic

Authored by antonanikin on Aug 22 2018, 11:33 AM.

Details

Summary

The recommendation is to use the 4-arg overload, which takes a context object so that the lambda isn't executed when the context object is deleted.

Diff Detail

Repository
R32 KDevelop
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
antonanikin created this revision.Aug 22 2018, 11:33 AM
Restricted Application added a project: KDevelop. · View Herald TranscriptAug 22 2018, 11:33 AM
antonanikin requested review of this revision.Aug 22 2018, 11:33 AM
antonanikin added inline comments.Aug 22 2018, 11:37 AM
plugins/debuggercommon/midebugsession.cpp
556–557

Here we suppress warning instead of fixing because of suitable receiver missing. Maybe we can use qApp as a receiver?

kfunk added a subscriber: kfunk.Aug 22 2018, 12:12 PM
kfunk added inline comments.
plugins/debuggercommon/midebugsession.cpp
556–557

QTimer::singleShot(5000, this, [this]() {...} or what am I missing?

When using the this as context object you can also simplify the lambda-body, i.e. remove the QPointer helper altogether.

antonanikin added inline comments.Aug 22 2018, 12:29 PM
plugins/debuggercommon/midebugsession.cpp
556–557

We can't use this here. On timeout our object (this) may be already destroyed. Therefore we use QPointer and check it for nullptr in lambda body.

antonanikin added inline comments.Aug 22 2018, 12:31 PM
plugins/debuggercommon/midebugsession.cpp
556–557

Although I was wrong, sorry - we can (and should) use this here. Will update the revision.

  • Remove QPointer
antonanikin marked 4 inline comments as done.Aug 22 2018, 12:39 PM
kfunk accepted this revision.Aug 22 2018, 12:40 PM
kfunk added inline comments.
appimage/kdevelop-recipe-centos6.sh
33 ↗(On Diff #40221)

Unrelated. I guess wrong arc usage? :)

plugins/debuggercommon/midebugsession.cpp
556–557

Yes, I think like this it should work. The QPointer was needed when QTimer::singleShotdidn't allow context objects (before Qt 5.4 iirc).

This revision is now accepted and ready to land.Aug 22 2018, 12:40 PM
  • Rebase to 5.3
kfunk accepted this revision.Aug 22 2018, 12:48 PM
  • Rebase to master (sorry for unnecessary steps)
This revision was automatically updated to reflect the committed changes.