Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions desktop/src-tauri/src/macos_file_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ mod tests {
env!("CARGO_MANIFEST_DIR"),
"/vendor/rfd/src/backend/macos/file_dialog/panel_ffi.rs"
));
const RFD_MODAL: &str = include_str!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/vendor/rfd/src/backend/macos/modal_future.rs"
));

#[test]
fn patched_wry_cancels_when_nsopenpanel_is_nil() {
Expand Down Expand Up @@ -67,4 +71,16 @@ mod tests {
"typed NSSavePanel::savePanel panics on nil"
);
}

#[test]
fn patched_rfd_nil_panel_returns_cancelled_future() {
assert!(
RFD_MODAL.contains("NSModalResponseCancel"),
"nil panel must complete the modal future as cancelled"
);
assert!(
RFD_MODAL.contains("return Self { state }"),
"ModalFuture::new returns Self; a bare `return;` on the sync nil-panel path is E0069"
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,10 @@ impl<R: 'static + Default, D: AsModal + 'static> ModalFuture<R, D> {

if let Some(mtm) = MainThreadMarker::new() {
let Some(modal) = build_modal(mtm) else {
dialog_callback(state, NSModalResponseCancel);
return;
// Constructor returns Self. Complete as cancelled when
// NSOpenPanel/NSSavePanel is nil (E0069 on a unit return).
dialog_callback(state.clone(), NSModalResponseCancel);
return Self { state };
};
let inner = modal.inner_modal().retain();

Expand Down