Repository navigation
Fix duplicate default layer with a custom layer filter - #427
Merged
Merged
Conversation
LayerContents::load decided whether to synthesize an empty default layer by checking LayerFilter::includes_default_layer(), which only knows about the all/load_default flags. A custom filter_layers closure that admitted the real default layer got the placeholder pushed anyway, so the layer set ended up with two entries pointing at glyphs/, and saving would nondeterministically clobber the real layer's contents.plist with the empty one's. Push the placeholder only when no loaded layer already has the default glyphs directory, and still fall through to MissingDefaultLayer when all/load_default was requested but the UFO genuinely has no default layer.
anthrotype
reviewed
Oct 7, 2026
| fn test_filter_admits_default_layer_no_duplicate() { | ||
| let ufo_path = "testdata/MutatorSansLightWide.ufo"; | ||
| let request = DataRequest::none() | ||
| .filter_layers(|name, _path| name == "public.default" || name == "foreground"); |
Collaborator
There was a problem hiding this comment.
the docstring says the filter admits the default layer "by name or by path", but the test only goes by name (and "public.default" doesn't match anything in this fixture, the default layer is called "foreground"). Maybe you can add a second request with |_, p| p == Path::new("glyphs"), since a path-only filter hits the same duplicate on main
anthrotype
approved these changes
Oct 7, 2026
A path-only filter hit the same duplicate layer bug. Also drop the public.default check, which never matched in this UFO.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
another funny little bug I found in the course of some other work:
LayerContents::load decided whether to synthesize an empty default layer by checking LayerFilter::includes_default_layer(), which only knows about the all/load_default flags. A custom filter_layers closure that admitted the real default layer got the placeholder pushed anyway, so the layer set ended up with two entries pointing at glyphs/, and saving would nondeterministically clobber the real layer's contents.plist with the empty one's.
Push the placeholder only when no loaded layer already has the default glyphs directory, and still fall through to MissingDefaultLayer when all/load_default was requested but the UFO genuinely has no default layer.