File: README-lambda-in-connect.md

package info (click to toggle)
clazy 1.17-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,248 kB
  • sloc: cpp: 23,552; python: 1,450; xml: 450; sh: 237; makefile: 46
file content (13 lines) | stat: -rw-r--r-- 530 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
# lambda-in-connect

Warns when a lambda inside a connect captures local variables by reference.
This usually results in a crash since the lambda might get called after the captured variable went out of scope.

#### Example:
````
    int a;
    connect(obj, &MyObj::mySignal, [&a]{ ... });
````
Although it's dangerous to capture by reference in other situations too, this check only warns for
connects, otherwise it would generate false-positives in legitimate situations where you only
use the lambda before going out of scope.