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

Panic in accesskit when using dialog box #6015

Open
oswald2 opened this issue Aug 31, 2024 · 3 comments · May be fixed by #6952
Open

Panic in accesskit when using dialog box #6015

oswald2 opened this issue Aug 31, 2024 · 3 comments · May be fixed by #6952
Labels
a:accessibility Support for assistive technologies (mS,bT) bug Something isn't working

Comments

@oswald2
Copy link

oswald2 commented Aug 31, 2024

Version: slint 1.7.2
Language: Rust
OS: Ubuntu 24.04

When opening a dialog box, main panics with:

thread 'main' panicked at /home/oswald/.cargo/registry/src/index.crates.io-6f17d22bba15001f/accesskit_consumer-0.24.0/src/tree.rs:272:13:
Tried to initialize the accessibility tree without a root tree. TreeUpdate::tree must be Some.
stack backtrace:
   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: accesskit_consumer::tree::Tree::new
   3: accesskit_atspi_common::adapter::Adapter::with_wrapped_action_handler
   4: <i_slint_backend_winit::winitwindowadapter::WinitWindowAdapter as i_slint_core::window::WindowAdapterInternal>::handle_focus_change
   5: i_slint_core::window::WindowInner::set_focus_item
   6: wyrdoscope::ui::event_dialog::display_new_time_event_dialog::slint_generatedNewEventDialog::NewEventDialog::new

This worked with the 1.6.x versions of slint (recently upgraded to 1.7.2).

The dialog is defined like this:

pub fn display_new_time_event_dialog<F>(
    time: &DateTime<Local>,
    name: &str,
    comment: &str,
    set_time_editable: bool,
    on_ok: F,
) where
    F: 'static + Fn(&DateTime<Local>, &str, &str),
{
    slint::slint! {

        import { LineEdit , TextEdit, StandardButton} from "std-widgets.slint";
        export component NewEventDialog inherits Dialog {
            forward-focus: time_edit;
            in-out property <string> time;
            in-out property <string> name;
            in-out property <string> comment;
            in property <bool> time-editable;

            VerticalLayout {
                spacing: 4px;

                Text {
                    text: "Time:";
                }

                time_edit := LineEdit {
                    text <=> time;
                    enabled: time-editable;
                    width: 300px;
                }

                Text {
                    text: "Name:";
                }

                name_edit := LineEdit {
                    text <=> name;
                    enabled: true;
                    width: 300px;
                }

                Text {
                    text: "Comment:";
                }

                TextEdit {
                    text <=> comment;
                    enabled: true;
                    width: 300px;
                    height: 300px;
                }
            }

            StandardButton {
                kind: cancel;
            }

            StandardButton {
                kind: ok;
            }

        }
    }

    let dialog = NewEventDialog::new().unwrap();
    let weak_dialog = dialog.as_weak();
    let weak_dialog2 = weak_dialog.clone();

    dialog.set_time(format_time(time).into());
    dialog.set_time_editable(set_time_editable);
    dialog.set_name(name.into());
    dialog.set_comment(comment.into());

    dialog.on_ok_clicked(move || {
        let dialog = weak_dialog.unwrap();
        let _ = dialog.hide();
        on_ok(&dialog.get_time(), &dialog.get_name(), &dialog.get_comment());
    });

    dialog.on_cancel_clicked(move || {
        let dialog = weak_dialog2.unwrap();
        let _ = dialog.hide();
    });

    let _ = dialog.run();
}

Anything I am doing wrong here, or is this a bug?

@tronical tronical added bug Something isn't working a:accessibility Support for assistive technologies (mS,bT) labels Aug 31, 2024
@tronical
Copy link
Member

This is definitely a bug :(

@oswald2
Copy link
Author

oswald2 commented Nov 30, 2024

Just for my curiosity: is this worked on? Because of this panic, I still use slint 1.6.0 and cannot go higher.

@tronical
Copy link
Member

Unfortunately I'm not actively working on it. But your ping reminded me to take another look, and I see now how this could happen. We need to protect handle_focus_change for notifying AccessKit before the initial tree has been requested. This shouldn't be difficult to do.

tronical added a commit that referenced this issue Dec 1, 2024
…pdate

This is a prospective fix to avoid sending `tree: None` as the first tree update.

Fixes #6015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:accessibility Support for assistive technologies (mS,bT) bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants