slint-ui / slint

Slint is a declarative GUI toolkit to build native user interfaces for Rust, C++, or JavaScript apps.
https://slint.dev
Other
17.72k stars 615 forks source link

Crashed due to ComboBox when clicking it #5558

Closed wuanzhuan closed 4 months ago

wuanzhuan commented 4 months ago

I think because of the ComboBox is in PopupWindow. slint version is 1.60. recurrent in slintpad as follows:

import { Button, Palette, Switch, ComboBox, ListView, VerticalBox, HorizontalBox } from "std-widgets.slint";

export component LogConfig {
    callback selected_level(/*level*/string);

    button := Button {
        width: self.preferred-width;
        height: self.preferred-height;
        text: @tr("Log Config");
        clicked => {
            popup.show()
        }
    }

    popup := PopupWindow {
        y: button.height + 4mm;
        close-on-click: false;

        Rectangle {
            background: Palette.background;
            border-width: 2px;
            border-color: Palette.border;

            VerticalBox {
                HorizontalLayout {
                    height: self.preferred-height;
                    alignment: end;

                    Button {
                        padding: 0px;
                        width: self.preferred-width;
                        height: self.preferred-height;
                        text: "X";

                        clicked => {
                            popup.close();
                        }
                    }
                }
                VerticalBox {
                    HorizontalBox {
                        height: self.preferred-height;
                        alignment: start;

                        Text {
                            vertical-alignment: center;
                            text: @tr("level: ");
                        }
                        ComboBox {
                            model: ["trace", "debug", "info", "warn", "error"];
                            current-value: "trace";
                            selected(value) => {
                                selected_level(value)
                            }
                        }
                    }
                }
            }
        }
    }
}
ogoffart commented 4 months ago

Thanks for filling an issue.

This is a duplicate of issue #4300 (which seems to be caused by https://github.com/slint-ui/slint/issues/4356 ) I'm closing this issue as duplicate, thanks anyway for taking the time to report the issue and please :+1: that issue.