Fix #14983 (GUI: exclude file with relative path) - #8804
Open
danmar wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses GUI project-file path handling for excluded paths by centralizing “make path relative to project directory” logic in ProjectFile, reusing it in the dialog, and adding regression tests.
Changes:
- Introduce
ProjectFile::getRelativePath()to convert absolute paths to project-relative paths with a cutoff for paths that traverse too far upward. - Update
ProjectFileDialogbrowse helpers to use the centralized relative-path logic. - Normalize excluded paths in
ProjectFile::setExcludedPaths()and add unit tests covering relative/absolute edge cases.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| gui/test/projectfile/testprojectfile.h | Adds new test slot declarations for excluded-path relativization behavior. |
| gui/test/projectfile/testprojectfile.cpp | Adds tests validating when excluded paths are converted to relative vs kept absolute. |
| gui/projectfiledialog.cpp | Uses ProjectFile::getRelativePath() instead of duplicating relative-path conversion logic. |
| gui/projectfile.h | Declares the new getRelativePath() helper with documentation. |
| gui/projectfile.cpp | Implements getRelativePath() and applies it when setting excluded paths. |
Suppressed comments (1)
gui/test/projectfile/testprojectfile.cpp:226
- This comment says "more than 2 parent folders" but the behavior under test keeps the path absolute when the relative form would start with "../.." (i.e. 2 or more levels up). Please update the comment to match the implemented threshold.
// Absolute path is kept as-is when making it relative would require walking up more than 2 parent folders
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+450
to
+455
| /** | ||
| * @brief Convert an absolute path to a path relative to this project's directory. | ||
| * If the relative path would need to walk up more than 2 parent folders | ||
| * (i.e. "../../...") the absolute path is returned unchanged instead. | ||
| * @param absolutePath Absolute path to convert. | ||
| */ |
| QCOMPARE(settings.userIncludes.size(), 0); | ||
| } | ||
|
|
||
| // Absolute path is made relative when it does not require walking up more than 2 parent folders |
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.
No description provided.