Repository navigation
fix(ui): export standalone tables from the Layers pane and Command Search #3119
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
Changes from all commits
ac46666
dba5335
d6ae8ba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,12 +39,21 @@ pub(crate) fn writing(app: &RustGisApp) -> Option<&str> { | |
| app.export_job.as_ref()?.writes.as_deref() | ||
| } | ||
|
|
||
| /// Refuses another export while one runs, whichever way it would run (one at a time). | ||
| /// Refuses an export while another runs, whichever way it would run (one at a time), or while a | ||
| /// read or table edit is still to land. | ||
| pub fn idle(app: &RustGisApp) -> Result<(), String> { | ||
| match &app.export_job { | ||
| Some(job) => Err(crate::i18n::fmt("{tool} is still running: wait for it, or cancel it.", &[("tool", tl_raw!(job.name))])), | ||
| None => Ok(()), | ||
| if let Some(job) = &app.export_job { | ||
| return Err(crate::i18n::fmt("{tool} is still running: wait for it, or cancel it.", &[("tool", tl_raw!(job.name))])); | ||
| } | ||
| // A read or table edit on its own thread changes the data only when it lands: an export now | ||
| // would write the data without it. | ||
| if let Some(read) = crate::readjob::under_way(app) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This guard refuses every export (Export Features, Export Orbit, a field package save and annotation export) while any read is queued or running, not only a table edit. A slow Add Data of an unrelated file now blocks exporting the active layer, and the PR description doesn't say the refusal reaches those commands. The rule fits the table-edit case. Consider limiting it to reads and edits that touch the data being exported, or stating in the PR description that the refusal is intended for every export. Separately, the Category: quality
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Intended for every export: one at a time, as exports already are with each other, and simpler to trust than working out which data each read touches. The PR description now says so. The waiting read's name is translatable (the "A read" fallback is wrapped in |
||
| return Err(crate::i18n::fmt( | ||
| "{read} is still running: wait for it, or cancel it, then export, so the file holds what it changes.", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For a read that is only queued, the message says it "is still running", and the tail "so the file holds what it changes" suggests this export would miss that read's data. For an unrelated read such as Add Data it wouldn't, so the wording could mislead. A wording like "is queued or running" would fit both cases. The test Category: quality
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fair: "is queued or running" would fit both, and the test's prefix would move with it. Left for the release quality pass, as the message is correct about what the user should do (wait or cancel) in both cases. |
||
| &[("read", tl_raw!(read))], | ||
| )); | ||
| } | ||
| Ok(()) | ||
| } | ||
|
|
||
| /// Starts `command` ([`exports::runs_in_background`]) with `p` on a thread of its own. One at a | ||
|
|
@@ -187,6 +196,34 @@ mod tests { | |
| assert_eq!(steps[1].params, again); | ||
| } | ||
|
|
||
| /// A table edit still on the reads worker would be missing from the file: the export is | ||
| /// refused, naming it, until the edit lands, and then holds it. | ||
| #[test] | ||
| fn an_export_waits_for_a_table_edit_under_way() { | ||
| let mut app = RustGisApp::with_sample(); | ||
| app.run("layer.addDataText", json!({"fileName": "ranks.csv", "text": "name,score\na,1\n"})).unwrap(); | ||
| app.reads_off_frame = true; | ||
| let dir = tempfile::tempdir().unwrap(); | ||
| let path = dir.path().join("ranks.csv"); | ||
| let export = json!({"table": "ranks", "path": path}); | ||
| app.run("edit.setValue", json!({"table": "ranks", "row": 0, "field": "score", "value": 5})).unwrap(); | ||
| assert_eq!(crate::readjob::under_way(&app), Some("Edit Attribute"), "the edit runs on the reads worker"); | ||
| let refused = app.run("share.exportTable", export.clone()).unwrap_err(); | ||
| assert!(refused.starts_with("Edit Attribute is still running"), "{refused}"); | ||
| assert!(app.export_job.is_none() && !path.exists()); | ||
| let end = std::time::Instant::now() + std::time::Duration::from_secs(30); | ||
| while crate::readjob::land(&mut app) { | ||
| assert!(std::time::Instant::now() < end, "the edit never landed"); | ||
| std::thread::sleep(std::time::Duration::from_millis(5)); // test-wait: the reads worker publishes its result to the frame's polled slot | ||
| } | ||
| assert_eq!(app.run("share.exportTable", export).unwrap()["started"], "Export Table"); | ||
| while land(&mut app) { | ||
| assert!(std::time::Instant::now() < end, "the export never landed"); | ||
| std::thread::sleep(std::time::Duration::from_millis(5)); // test-wait: export workers publish completion to the frame's polled slot | ||
| } | ||
| assert_eq!(std::fs::read_to_string(&path).unwrap(), "name,score\na,5\n"); | ||
| } | ||
|
|
||
| /// Delivers actual failed and cancelled export runs without a thread timing race. Neither | ||
| /// may enter Record Task; a written file whose completion is refused is excluded too. | ||
| #[test] | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.