Only re-create elements if the model actually changed

Being dirty is not enough

Fixes #7245

ChangeLog: Elements of a `for` now only get re-created if the model is
changed, not if it is only dirty
This commit is contained in:
Olivier Goffart 2025-01-06 11:37:50 +01:00
parent 4da2cb4471
commit 87d86ae7d2
6 changed files with 116 additions and 12 deletions

View file

@ -1146,10 +1146,14 @@ public:
void ensure_updated(const Parent *parent) const
{
if (model.is_dirty()) {
inner = std::make_shared<RepeaterInner>();
if (auto m = model.get()) {
inner->model = m;
m->attach_peer(inner);
auto old_model = model.get_internal();
auto m = model.get();
if (!inner || old_model != m) {
inner = std::make_shared<RepeaterInner>();
if (m) {
inner->model = m;
m->attach_peer(inner);
}
}
}

View file

@ -184,6 +184,8 @@ struct Property
{
}
const T &get_internal() const { return value; }
private:
cbindgen_private::PropertyHandleOpaque inner;
mutable T value {};