Bug 356372 - new check: Find lambdas capturing local variables by ref, when inside connects
Summary: new check: Find lambdas capturing local variables by ref, when inside connects
Status: RESOLVED FIXED
Alias: None
Product: clazy
Classification: Developer tools
Component: general (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR wishlist
Target Milestone: ---
Assignee: Sergio Martins
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-12-07 19:21 UTC by Sergio Martins
Modified: 2016-02-17 21:21 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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