Skip to content
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

Property change is propagated too far (even when the value remains the same) #5209

Closed
Justyna-JustCode opened this issue May 9, 2024 · 2 comments
Labels
duplicate This issue or pull request already exists

Comments

@Justyna-JustCode
Copy link

openSUSE Leap 15.4
Slint 1.5 + Rust

Minimal example:

export component MainWindow inherits Window {
    property<bool> is-portrait: self.width < self.height;

    if self.is-portrait: Rectangle {
        width: 30%; height: 30%;
        background: red;

        init => { debug("Red rectangle created"); }
    }
    if !self.is-portrait: Rectangle {
        width: 30%; height: 30%;
        background: green;

        init => { debug("Green rectangle created"); }
    }
}

I expected that items would only be re-created when the orientation actually changes (i.e., when is-portrait is changed from false to true or from true to false). Still, in reality, I see the debug log ("... rectangle created") every time I resize the window, even when orientation stays the same (and a rectangle of a given color remains visible).

@ogoffart
Copy link
Member

ogoffart commented May 9, 2024

Thanks for the bug report.
This is actually a duplicate of #3953
So I'm closing this bug as duplicated.
But thanks anyway for taking the time to report the bug with a nice testcase.

@ogoffart ogoffart closed this as not planned Won't fix, can't repro, duplicate, stale May 9, 2024
@ogoffart ogoffart added the duplicate This issue or pull request already exists label May 9, 2024
@Justyna-JustCode
Copy link
Author

Thanks! I tried to find any existing issues, but it seems I failed 😉
I just wanted to mention (since the other issue is mentioning conditional elements strictly) that it seems that conditional elements are not required for the bug to occur.

I also checked it in this configuration:

    Rectangle {
        width: 30%; height: 30%;
        background: root.is-portrait ? red : green;

        function on-is-portrait-changed(is-portrait: bool, returnValue: float) -> float {
            debug("Is portrait:", is-portrait);
            return returnValue;
        }
        opacity: self.on-is-portrait-changed(root.is-portrait, 1);
    }

and this debug log is also visible for every window resize.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants