Fix global changed handler inlining#12155
Open
LeonMatthes wants to merge 4 commits into
Open
Conversation
LeonMatthes
commented
Jun 18, 2026
Member
- Add regression test for Crash when source element of callback gets deleted #6426
- remove_aliases: Refine add_links across components
- Fix remove_aliases merging unlinked global <=> component bindings
Member
|
Also please change the title, this does not fix that issue. That issue is unrelated. |
ogoffart
reviewed
Jun 18, 2026
| // 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). |
Member
There was a problem hiding this comment.
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.
6eec38e to
b2f2dde
Compare
Member
Author
Ah, right, sorry I mixed that up. |
ogoffart
reviewed
Jun 18, 2026
| // 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). |
Member
There was a problem hiding this comment.
this is an implementation detail of the interpreter. But we'd have other error with the LLR or generated code.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.