Repository navigation
feat(layout): a picture remembers its file, names it when its image is missing, and reads it again #3211
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
feat(layout): a picture remembers its file, names it when its image is missing, and reads it again #3211
Changes from all commits
385bc44
b4ab52f
c71b1ee
9799030
bc9ac74
0be0acf
5aac0b6
c090ee9
5aba35b
c9fe044
ac1d420
3805a78
c9411a9
ac3f257
3a33d6b
8b6b795
7d52c8a
3be5e79
0ff0927
d50ef30
e0df2b0
357f7bd
ec716b6
1569395
f164db3
65c499f
46d1d6e
6eb9d72
434ad0c
9a212a2
f3c947a
b9104ce
3d7e696
cdc4c6e
0018335
b861d48
9cbbfa2
22b63e4
76d3b97
d587a81
999f132
e87e83b
98ffe9c
78d1018
511da85
87a3c10
e6815c9
0b7a762
3645393
570a459
3348e6c
92993fd
e19286b
48cec5b
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 |
|---|---|---|
|
|
@@ -61,7 +61,7 @@ fn layout_bytes_for( | |
| /// millimetres from the page's top left), drawn at that `dpi` rather than cut out of the whole | ||
| /// page: what the assistant's `view_map` shows of a layout. It says what exporting the page says | ||
| /// of it: texts cut off, named fonts still being read, frames drawn without their cast shadows, | ||
| /// charts' notices. | ||
| /// pictures drawn as a grey box, charts' notices. | ||
| pub fn layout_png(s: &mut Session, li: usize, dpi: f64, region: Option<[f64; 4]>) -> Result<Vec<u8>, String> { | ||
| let layout = s.project.layouts.get(li).ok_or("no layout")?.clone(); | ||
| if let Some(note) = named_fonts_unread(&layout) { | ||
|
|
@@ -83,6 +83,10 @@ pub fn layout_png(s: &mut Session, li: usize, dpi: f64, region: Option<[f64; 4]> | |
| if let Some(r) = region { | ||
| gaps.retain(|g, _| layout.element(g.frame).is_some_and(|e| rustgis_render::layout::meets(e, r, 0.0))); | ||
| } | ||
| let mut grey = rustgis_render::layout::pictures_not_drawn(&layout); | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
| if let Some(r) = region { | ||
| grey.retain(|g| layout.element(g.id).is_some_and(|e| rustgis_render::layout::meets(e, r, 0.0))); | ||
| } | ||
| let mut profiles: ProfileNotes = | ||
| rustgis_render::layout::profiles_not_drawn(&layout, &s.project.maps).into_iter().map(|n| (n, 1)).collect(); | ||
| if let Some(r) = region { | ||
|
|
@@ -111,6 +115,7 @@ pub fn layout_png(s: &mut Session, li: usize, dpi: f64, region: Option<[f64; 4]> | |
| if let Some(note) = rustgis_render::layout::sections_notice(&gaps, 1) { | ||
| s.warn(note); | ||
| } | ||
| say_pictures_not_drawn(s, &grey, ""); | ||
|
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 notice is said on every call of Confidence: medium on the mechanism, low on how often users see it. Category: quality
Contributor
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. Agreed on the mechanism, and left as it is for the reason given: every notice |
||
| for note in rustgis_render::layout::profiles_notice(&profiles, 1) { | ||
| s.warn(note); | ||
| } | ||
|
|
@@ -318,6 +323,8 @@ pub(in crate::cmd::layout) fn layout_bytes_inner( | |
| if let Some(note) = rustgis_render::layout::sections_notice(&gaps, pages.len()) { | ||
| s.warn(note); | ||
| } | ||
| // A series' pages move its frame only: its pictures are the same on every page. | ||
| say_pictures_not_drawn(s, &rustgis_render::layout::pictures_not_drawn(&saved), ""); | ||
| for note in rustgis_render::layout::profiles_notice(&profiles, pages.len()) { | ||
| s.warn(note); | ||
| } | ||
|
|
@@ -555,6 +562,7 @@ fn layout_svg(s: &mut Session, li: usize, dpi: f64, download: Option<(crate::cmd | |
| let clipped = rustgis_render::layout::clipped_text(layout, &s.project.maps, dpi, &info); | ||
| let note = rustgis_render::layout::clipped_text_notice(layout, &clipped); | ||
| let gaps = rustgis_render::layout::sections_not_drawn(layout, &s.project.maps).into_iter().map(|g| (g, 1)).collect(); | ||
| let grey = rustgis_render::layout::pictures_not_drawn(layout); | ||
| let profiles: ProfileNotes = rustgis_render::layout::profiles_not_drawn(layout, &s.project.maps).into_iter().map(|n| (n, 1)).collect(); | ||
| let ((drawn, unfitted), charts) = rustgis_render::layout::drawn_charts(|| { | ||
| rustgis_render::layout::unfitted_legends(|| { | ||
|
|
@@ -568,6 +576,7 @@ fn layout_svg(s: &mut Session, li: usize, dpi: f64, download: Option<(crate::cmd | |
| for note in [note, rustgis_render::layout::sections_notice(&gaps, 1)].into_iter().flatten() { | ||
| s.warn(note); | ||
| } | ||
| say_pictures_not_drawn(s, &grey, ""); | ||
| for note in rustgis_render::layout::profiles_notice(&profiles, 1) { | ||
| s.warn(note); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a twin the change missed.
picture_file(path, path)still names the full path in a refusal, so on this route (graphics.add, and presentations, which sharepicture()) a login-shaped path reaches the command error, the notice and the Assistant's tool result.user:pw@host:/a.pngis refused as an address on the layout commands and never echoed there, but here a missing file givesuser:pw@host:/a.png: No such file or directory. The layout commands now name the file by its name only (picture_file_name), so the leak stays open for map graphics.Pre-existing on main, and the PR says map graphics are unchanged on purpose. But this change moved the shared helper (
read_picture_file/picture_file) in front of both routes, so the same fix should either follow here (refuse an address before any read, and name the file by its name), or the PR should say why graphics keep the echo. Read from the code, not run. Confidence: medium.Category: security
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left as it is, on purpose, and here is why.
graphics.addand presentations name the path the caller gave in a refusal on main, and this pull request does not change what they say:picture_file(path, path)is that route's old behaviour, word for word, and the new test asserts it (graphics.addwith a missing file still answers{path}: {error}). The helper was split so that the layout commands could name a file their own way; the map-graphics route got no new input, no new caller and no new text. Changing it (refusing an address before the read, naming the file by its name) is a behaviour change to two commands outside layout pictures, with their own tests, parameter text and user guide passages, so it belongs in its own change where it can be reviewed as one; the PR description says map graphics' refusals are unchanged.