Repository navigation
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
WalkthroughmacOS file-dialog filters now use a shared helper to convert extensions into recognized content types. Open and save dialogs allow other file types when no content types are recognized. The changelog documents the crash fix. ChangesmacOS dialog filter handling
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix · Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to The dialog change is mergeable after normal checks. Unresolvable filters no longer produce nil content types, and broader matching for compound extensions is intentional. Pre-merge checks |
|
|
Testing on macOS 14.6 is done, with the results in the description, so this is ready for review. The PR checks are waiting for workflow approval. |
Description
On macOS 11 and later the v2 Open and Save dialogs build their filter list with
[UTType typeWithFilenameExtension:]and add the result to an array without a nil check. That call returns nil for anything that is not a single plain extension, so a pattern such as*.tar.gzorbusted.exethrowsNSInvalidArgumentExceptionand the app aborts.Both dialogs now share one helper. An extension that does not resolve is retried with its last component, so
tar.gzfilters on gzip andbusted.exeon exe, and anything that still does not resolve is skipped. If nothing resolves, the dialog opens without a filter, which is what the save dialog already did for an empty list. UTType cannot express a compound extension or a full file name, so those two cases become a slightly wider filter rather than an exact one.I did not port the v3 fix from #5678 as is. On macOS 11 and later
setAllowedFileTypes:andsetAllowedContentTypes:share the same storage, so calling the first after the second drops the types that did resolve. With*.png;*.tar.gzthe png filter disappears: a small AppKit check on macOS 14.6 showsallowedContentTypesgoing frompublic.pngto empty aftersetAllowedFileTypes:@[@"tar.gz"].Fixes #5554
Type of change
How Has This Been Tested?
The darwin package has no Go test harness and cgo cannot be used from a
_test.gofile, so I tested with a minimal v2 app built once against master and once against this branch. It opens the dialog fromOnDomReadywith a single filter pattern and reports success if the process is still alive three seconds later.*.png;*.jpg, open and save: the dialog opens on master and on this branchbusted;busted.exe, open and save: master aborts with "object cannot be nil", this branch opens the dialog*.tar.gz, open and save: master aborts, this branch opens the dialog*.png;*.tar.gz, open and save: master aborts, this branch opens the dialogI also compiled the helper into a small harness that prints the resolved types, and
*.png;*.tar.gzgivespublic.png, org.gnu.gnu-zip-archive.go test ./...inv2passes with Go 1.25.14, andclang -Wall -Wunguarded-availability -mmacosx-version-min=10.13reports no new warnings forWailsContext.m.Test Configuration
Checklist:
website/src/pages/changelog.mdxwith details of this PR (v3 changelog entries are added automatically)Summary by CodeRabbit
.tar.gz, or unrecognized extensions. Dialogs now handle these filters more reliably, allowing files to be selected without the app crashing.