mirror of
https://github.com/slint-ui/slint.git
synced 2025-09-30 22:01:13 +00:00
Only the computation of the model needs to be done in the evaluation scope for it
Otherwise any change in any of the properties of the delegate will cause the model to be reset.
This commit is contained in:
parent
c8fa3354be
commit
f5aeb9ba60
4 changed files with 44 additions and 42 deletions
|
@ -124,7 +124,7 @@ struct PropertyTracker
|
|||
}
|
||||
|
||||
template<typename F>
|
||||
void evaluate(const F &f) const {
|
||||
auto evaluate(const F &f) const -> std::enable_if_t<std::is_same_v<decltype(f()), void>> {
|
||||
cbindgen_private::sixtyfps_property_tracker_evaluate(
|
||||
&inner,
|
||||
[](void *f){ (*reinterpret_cast<const F*>(f))(); },
|
||||
|
@ -132,6 +132,13 @@ struct PropertyTracker
|
|||
);
|
||||
}
|
||||
|
||||
template<typename F>
|
||||
auto evaluate(const F &f) const -> std::enable_if_t<!std::is_same_v<decltype(f()), void>, decltype(f())> {
|
||||
decltype(f()) result;
|
||||
this->evaluate([&] { result = f(); } );
|
||||
return result;
|
||||
}
|
||||
|
||||
private:
|
||||
cbindgen_private::PropertyTrackerOpaque inner;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue