1// Copyright © SixtyFPS GmbH <info@slint.dev>
2// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-1.1 OR LicenseRef-Slint-commercial
3
4use ::slint::slint;
5
6#[test]
7fn show_maintains_strong_reference() {
8 i_slint_backend_testing::init_with_event_loop();
9
10 slint!(export component TestWindow inherits Window {
11 callback root-clicked();
12 TouchArea {
13 clicked => { root.root-clicked(); }
14 }
15 });
16
17 let window = TestWindow::new().unwrap();
18
19 let window_weak = window.as_weak();
20 let window_weak_2 = window_weak.clone();
21
22 slint::invoke_from_event_loop(move || {
23 window_weak_2.upgrade().unwrap().hide().unwrap();
24 slint::quit_event_loop().unwrap();
25 })
26 .unwrap();
27
28 window.show().unwrap();
29 drop(window);
30 slint::run_event_loop().unwrap();
31
32 assert!(window_weak.upgrade().is_none());
33}
34