ElyDoc: closing a tab takes its export or print dialog, no crash (D-01)

This commit is contained in:
ZacharyZhang-NY committed 2026-10-09 12:06:47 -04:00
1 parent ec87e28a46
commit 1f4807c81c
5 files changed
+28 -2

No files matched your search

+8
View File
@@ -85,6 +85,14 @@ impl Host for Docs {
self.offer_spelling(id, view, cx);
}
/// A dialog about a closed tab goes with it.
fn tab_closed(&mut self, tab: &ely_office::Tab<Extra, ely_office::Lok>, cx: &mut Context<Self>) {
if matches!(self.dialog, Some(Dialog::Output { tab: of, .. }) if of == tab.id) {
self.dialog = None;
cx.notify();
}
}
fn search_leaves(&mut self, cx: &mut Context<Self>) {
self.mark_place(cx);
}
+1 -1
View File
@@ -29,7 +29,7 @@ impl Docs {
self.ask_output(true, cx);
}
fn ask_output(&mut self, print: bool, cx: &mut Context<Self>) {
pub(crate) fn ask_output(&mut self, print: bool, cx: &mut Context<Self>) {
let Some(tab) = self.active_tab() else {
let text = Docs::text(cx, "command.blocked.no_document", &[]);
return self.toast(text, Severity::Warning, cx);
+17
View File
@@ -246,3 +246,20 @@ fn a_quit_from_either_window_asks_first() {
}));
}
}
#[test]
fn closing_a_tab_takes_its_export_dialog() {
let dir = tempfile::tempdir().expect("a temp dir");
let mut cx = TestAppContext::single();
let Some(docs) = docs(&mut cx, dir.path()) else {
eprintln!("SKIP: no LOK build");
return;
};
let id = blank(&mut cx, &docs);
cx.update(|app| docs.update(app, |docs, cx| docs.ask_output(false, cx)));
assert!(cx.update(|app| matches!(docs.read(app).dialog, Some(crate::actions::Dialog::Output { .. }))));
with_window(&mut cx, &docs, |docs, window, cx| docs.request_close(id, After::Tab, window, cx));
settle(&cx, |app| docs.read(app).tab(id).is_none());
// Drawn now, a dialog for the gone tab would crash.
assert!(cx.update(|app| docs.read(app).dialog.is_none()), "the dialog went with its tab");
}
+1 -1
View File
@@ -47,7 +47,7 @@
- [ ] P-12 `unhook` 中途抛出时泄漏保留的对象
- [ ] P-13 优化导出的“之前”大小取磁盘文件而非当前文档
- [ ] P-14 文字块含控制字符时 JSON 回复不可解析
- [ ] D-01 导出或打印对话框开着时关闭其标签即崩溃
- [x] D-01 导出或打印对话框开着时关闭其标签即崩溃 — Docs 实现 tab_closed,关标签即撤下其导出对话框;R1 PASS
- [ ] D-02 邮件合并以当前标签为模板,预览后生成的每份都是同一条记录
- [ ] D-03 界面线程同步持 worker 锁读内核(样式、字体、书签、公式、分节名)
- [ ] D-04 一条批注的时间读不出,全部批注与修订都不显示
+1
View File
@@ -0,0 +1 @@
PASS