frontend: Fix profile import with trailing path slash - #13863
Open
Ushkalovk wants to merge 1 commit into
Open
Conversation
The directory chooser can return a path that ends with a separator, e.g. when the path is typed manually or on some platform dialogs. std::filesystem::path::filename() returns an empty string for such a path, so the imported profile gets an empty directory name and its files are copied directly into the profiles root instead of a new profile directory. No new profile appears in the profile list. Normalize the selected path with QDir::cleanPath() before building the filesystem path, which strips the trailing separator and yields the actual directory name.
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.
Description
Normalizes the directory selected in the profile import dialog with
QDir::cleanPath()before deriving the profile directory name from it.Motivation and Context
When the directory chooser returns a path with a trailing separator,
std::filesystem::path::filename()yields an empty string. The import then uses an empty directory name, copies the profile files into the profiles root and no new profile shows up in the list.Fixes #13862
How Has This Been Tested?
macOS 26, Xcode build. Imported a profile from a directory path with and without a trailing slash; both now create a correctly named profile that appears in the profile menu. Importing a profile whose directory name already exists still shows the "profile exists" warning.
Types of changes
Checklist: