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

Live preview crashes with PopupWindow #7775

Open
petiaccja opened this issue Mar 1, 2025 · 2 comments
Open

Live preview crashes with PopupWindow #7775

petiaccja opened this issue Mar 1, 2025 · 2 comments
Labels
a:language-interpreted Interpreter implementation and Rust API for it (slint-interpreter crate) (mO,bT) bug Something isn't working need triaging Issue that the owner of the area still need to triage

Comments

@petiaccja
Copy link

Bug Description

Live preview crashes with PopupWindow:

thread 'main' panicked at internal\interpreter\eval.rs:1842:71:
called `Option::unwrap()` on a `None` value
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
[Info  - 9:00:33 PM] Connection to server got closed. Server will restart.
true
The Slint Language Server crashed. This is a bug. Please open an issue on https://github.com/slint-ui/slint/issues
[Error - 9:00:33 PM] Server process exited with code 3221226505.

Steps to reproduce (see code below):

  1. Launch LivePreviewTest in live preview using VSCode's inline actions
  2. Click "Show warning" on the live preview window
  3. Click either "Continue" or "Cancel"
  4. Panic

Unfortunately I don't have the stacktrace as I'm not sure how to get it with the live preview. I haven't had the chance yet to test the Slint code by running the Rust application itself. I'm also unsure if the rest of the Slint code affects the live preview for these two files, but I would guess not.

Reproducible Code (if applicable)

// File "prototype_popup.slint"
import { Palette } from "std-widgets.slint";

export component PrototypePopup inherits PopupWindow {
    Rectangle {
        background: Palette.background;
        border-radius: 16px;
        drop-shadow-color: #00000080;
        drop-shadow-blur: 12px;
        drop-shadow-offset-x: 2px;
        drop-shadow-offset-y: 2px;
        opacity: 95%;
    }

    Rectangle {
        background: Palette.control-background;
        border-radius: 16px;
        opacity: 95%;
    }
}

// File "warning_popup.slint"
import { PrototypePopup } from "prototype_popup.slint";
import { Button } from "std-widgets.slint";

export component WarningPopup inherits PrototypePopup {
    width: 400px;
    height: self.min-height;
    in property <bool> continue-enabled: true;
    in property <bool> cancel-enabled: true;
    in property <string> continue-text: "Continue";
    in property <string> cancel-text: "Cancel";
    callback continued();
    callback cancelled();
    content := VerticalLayout {
        spacing: 12px;
        padding: 12px;
        HorizontalLayout {
            alignment: center;
            spacing: 6px;
            VerticalLayout {
                alignment: center;
                // Redacted (does not change behavior)
            }

            @children
        }

        HorizontalLayout {
            alignment: end;
            spacing: 6px;
            if root.continue-enabled: Button {
                text: root.continue-text;
                width: 96px;
                clicked => {
                    root.close();
                    root.continued();
                }
            }
            if root.cancel-enabled: Button {
                text: root.cancel-text;
                width: 96px;
                clicked => {
                    root.close();
                    root.cancelled();
                }
            }
        }
    }
}

export component LivePreviewTest {
    warning := WarningPopup {
        x: (root.width - self.width) / 2;
        y: (root.height - self.height) / 2;
        Text {
            text: "Bad things might happen!";
        }
    }

    Button {
        text: "Show warning";
        clicked => {
            warning.show();
        }
    }
}

Environment Details

  • Slint Version: 1.9.2
  • Platform/OS: Windows 11
  • Programming Language: Slint (live preview)
  • Backend/Renderer: live preview default
  • VSCode Extension Version: 1.10.0

Product Impact

No response

@petiaccja petiaccja added bug Something isn't working need triaging Issue that the owner of the area still need to triage labels Mar 1, 2025
@petiaccja
Copy link
Author

It may be useful info:

  • removing the callbacks from the clicked handlers does not panic
  • factoring out the clicked handler into a separate self-level function that calls both continued and close fixes the issue

@petiaccja
Copy link
Author

There is another related issue:

export component WarningPopup [...] {
    function continue() {
        root.close(); // << Problem here
        self.continued();
    }
}

export component LivePreviewTest {
    warning := WarningPopup {
        // ...
        continued => {} // << Problem here
    }

    // ...
}

If root.close() is present in WarningPopup's factored out click handler, then adding any callback handler for continue in a parent component will panic:

thread 'main' panicked at internal\interpreter\dynamic_item_tree.rs:1449:43:
called `Option::unwrap()` on a `None` value
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
[Info  - 11:04:17 AM] Connection to server got closed. Server will restart.
true
The Slint Language Server crashed. This is a bug. Please open an issue on https://github.com/slint-ui/slint/issues
[Error - 11:04:17 AM] Server process exited with code 3221226505.

@ogoffart ogoffart added the a:language-interpreted Interpreter implementation and Rust API for it (slint-interpreter crate) (mO,bT) label Mar 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:language-interpreted Interpreter implementation and Rust API for it (slint-interpreter crate) (mO,bT) bug Something isn't working need triaging Issue that the owner of the area still need to triage
Projects
None yet
Development

No branches or pull requests

2 participants