-
Notifications
You must be signed in to change notification settings - Fork 756
Fix recursion panic when PopupWindow.show() called in init callback (#9498) #9523
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Fix recursion panic when PopupWindow.show() called in init callback (#9498) #9523
Conversation
…lint-ui#9498) - Defer user_init() call using event loop in both Rust and C++ backends - Add fallback to synchronous call when event loop unavailable - Fixes issue where init callbacks calling popup.show() caused infinite recursion Changes: - internal/compiler/generator/rust.rs: Defer user_init via invoke_from_event_loop - api/cpp/include/slint_window.h: Defer user_init via slint_post_event - Applied to both ShowPopupWindow and ShowPopupMenu cases This change breaks the recursion by deferring the user_init execution, allowing the popup to be properly initialized before init callbacks run.
3e2a7e3
to
18b198b
Compare
Nice! Thanks for the contribution. This will fix #9498 Could you please try to add a test somewhere in tests/cases/ As for the CI errors:
But actually i am not quite sure that it is valid to call user_init later. Did you figure out what exactly was the recursion about? Is there perhaps another way to break the recursion? |
Thanks for the thorough review! You're absolutely right about the issues. Let me break down what I found and how I'm fixing it: What's Actually Happening So I dug deeper into the recursion, and here's the problem: When you call The recursion detector in The Fixes: C++ Side Rust Side Why Defer user_init? I considered a few approaches:
But deferring Current Status
The core insight is that doing UI operations during component construction is inherently risky - better to defer them slightly so everything is properly set up first. Should I finish up the Rust implementation and then move on to the interpreter? Or do you think there's a better approach I'm missing? |
@Rishant12220055 Are you actively tracking this?
There are no tests, unfortunately. I think with tests it would be easier to validate this approach. I'm a little unsure if a casually delated user-init is the right fix, or if there's a better solution. But a test would help work towards it. |
Problem
Calling
PopupWindow.show()
in aninit
callback causes "Recursion Detected" panics due to infinite recursion between popup initialization and user init callbacks.Solution
Changes
internal/compiler/generator/rust.rs
: Defer user_init viainvoke_from_event_loop
api/cpp/include/slint_window.h
: Defer user_init viaslint_post_event
ShowPopupWindow
andShowPopupMenu
casesThis change breaks the recursion by deferring the user_init execution, allowing the popup to be properly initialized before init callbacks run.
Testing
Verified the fix resolves the recursion issue while maintaining backward compatibility.