aui-framework / aui-framework/aui

Implicit capture of 'this' with a capture default of '=' is deprecated

Open
#654 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
600
Forks
44
Avg merge
17h 56m
Merged PRs (30d)
3

Description

AUI and AUI-based code relies of implicit capture of this pointer which might lead to memory-related issues. Because of this behaviour, I can't do:

```cpp
template
struct ListView {
contract::In> items;
contract::In selectionId;
contract::Slot onSelectionChange;

std::function<_(_)> body = ListViewDefaults::defaultBody;
std::function<_(_)> scrollArea = ListViewDefaults::defaultScrollArea;

_ operator()() {
return body(scrollArea(AUI_DECLARATIVE_FOR(i, items.value(), AVerticalLayout) { // <-- implcit capture of 'this'
return Label { "{}"_format(i) };
}));
}
};
```

The code above emits a warning and crashes.

When building AUI on any compiler, it spams with this warning. I suggest rethinking the code that relies on reasonably deprecated implicit capture of 'this' and leverage this warning to error.

Contributor guide

Open the contributing guide

Research direction

Start with the AUI_DECLARATIVE_FOR use in the ListView example and trace how it captures this. Search AUI and AUI-based code for the same implicit capture pattern, then build on a compiler that emits the warning to reproduce the crash. Done means the warning and crash are addressed without breaking the declarative UI behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
desktop
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.