Skip to content

Fix global changed handler inlining#12155

Open
LeonMatthes wants to merge 4 commits into
slint-ui:masterfrom
LeonMatthes:6426-fix-global-changed-handler-inlining
Open

Fix global changed handler inlining#12155
LeonMatthes wants to merge 4 commits into
slint-ui:masterfrom
LeonMatthes:6426-fix-global-changed-handler-inlining

Conversation

@LeonMatthes

Copy link
Copy Markdown
Member

@ogoffart

Copy link
Copy Markdown
Member

Also please change the title, this does not fix that issue. That issue is unrelated.

// into a global). The two endpoints are still meant to be linked at runtime, but the rejected
// target was never folded away, so we must not let `old_binding` carry that reference onto `to`
// via the `merge_with` below: that would leave the global singleton holding a reference to an
// instance element it cannot resolve (issue #6426 -- "accessing deleted parent" at runtime).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't refer to this issue, it is unrelated

(In fact, we probably should change the panic message because it may panic for more reason than this issue)

This is quite a long comment.

Two-way bindings should not pull the changed handler of an element onto
a global.
There was already some code in the remove_aliases pass to prevent this,
but it did not work correctly for the transitive two-way-bindings where
each individual edge was allowed, but the complete set caused the issue.
Links across components could previously be added that included change
handlers, if the link went through an intermediary without change
handlers.

So given properties;
Component::A
Component::B (has changed handler)
Global::C

which are linked via:
Component::A <=> Global::C
Component::A <=> Component::B

add_links would accept both connections into a property set, because the
two links are separately processed, and are individually mergable, but
the combination is problematic.

(Component::A <=> Global::C) goes across components, but has no change
handler, which we should allow.
But then adding (Component::A <=> Component::B) would introduce a change
handler across components, even though the link itself did not go across
components.

This new patch fixes this in add_links by inspecting the whole set to
determine if a new link would break any of the invariants.

WARNING: This is not yet complete, as remove_aliases does not correctly
respect the component set in this case yet and will merge the properties
regardless!

Related to slint-ui#6326
remove_aliases would by default always merge the two-way binding
onto the global.
This is problematic if the merged property contained another
two-way-binding that pointed to another element property.

For globals specifically, we need to instead make sure the merged
property stays originating at the element.
@LeonMatthes LeonMatthes changed the title Fix #6426 global changed handler inlining Fix global changed handler inlining Jun 18, 2026
@LeonMatthes LeonMatthes force-pushed the 6426-fix-global-changed-handler-inlining branch from 6eec38e to b2f2dde Compare June 18, 2026 15:18
@LeonMatthes

Copy link
Copy Markdown
Member Author

Also please change the title, this does not fix that issue. That issue is unrelated.

Ah, right, sorry I mixed that up.
PR is updated.

// into a global). The two endpoints are still meant to be linked at runtime, but the rejected
// target was never folded away, so we must not let `old_binding` carry that reference onto `to`
// via the `merge_with` below: that would leave the global singleton holding a reference to an
// instance element it cannot resolve ("accessing deleted parent" at runtime).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is an implementation detail of the interpreter. But we'd have other error with the LLR or generated code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants