aui icon indicating copy to clipboard operation
aui copied to clipboard

Cycling smart pointers when creating lambda signal-slot connection

Open Alex2772 opened this issue 3 years ago • 1 comments

auto surface = _new ...;
connect(clicked, surface, [surface]() {
  ...
});

In this example, surface is referenced in signal-slot connection lambda, causing the surface to never destroy by itself.

Alex2772 avatar Sep 14 '22 11:09 Alex2772

Workaround:

auto surface = _new ...;
connect(clicked, surface, [surface = surface.get()]() {
  ...
});

At least there are should be diagnostics for that.

Alex2772 avatar Mar 04 '24 13:03 Alex2772