Bug 356372

Summary: new check: Find lambdas capturing local variables by ref, when inside connects
Product: [Developer tools] clazy Reporter: Sergio Martins <smartins>
Component: generalAssignee: Sergio Martins <smartins>
Status: RESOLVED FIXED    
Severity: wishlist CC: eric.lemanissier, smartins, tcanabrava
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Sergio Martins 2015-12-07 19:21:21 UTC
Outside connects there are false-positives, but inside connects that would introduce a crash
Comment 1 Sergio Martins 2016-02-15 19:13:13 UTC
Hi Tomaz, I'll be taking this one. I hope you haven't started ;)
Comment 2 eric.lemanissier 2016-02-16 13:10:34 UTC
I would suggest disabling this warning if the signal sender or the context object is also on the stack. Ideally the warning should remain if the captured variable is deeper in the stack (toward the bottom) than the sender or context object
Comment 3 Sergio Martins 2016-02-17 21:21:50 UTC
Git commit d984f82856e12a2948f8aa0ab86950d30dd6bbd8 by Sergio Martins.
Committed on 17/02/2016 at 21:17.
Pushed by smartins into branch 'master'.

lambda-in-connect: Relax the warning if the sender is on the stack

The connection will disconnect when the sender goes out of scope
so it's safe. Unless the connect was made in a nested scope but that's rare, patches accepted.

M  +8    -0    checks/lambda-in-connect.cpp
M  +4    -0    tests/lambda-in-connect/main.cpp

http://commits.kde.org/clazy/d984f82856e12a2948f8aa0ab86950d30dd6bbd8