Skip to content

Fix #14983 (GUI: exclude file with relative path) - #8804

Merged
dmcppcheck merged 2 commits into
cppcheck-opensource:mainfrom
cppchecksolutions:fix-14983
Aug 21, 2026
Merged

Fix #14983 (GUI: exclude file with relative path)#8804
dmcppcheck merged 2 commits into
cppcheck-opensource:mainfrom
cppchecksolutions:fix-14983

Conversation

@danmar

@danmar danmar commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@danmar
danmar requested review from ludviggunne and a lite review from Copilot August 20, 2026 19:57

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ProjectFileDialog browse 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 thread gui/projectfile.h
Comment thread gui/test/projectfile/testprojectfile.cpp Outdated
ludviggunne
ludviggunne previously approved these changes Aug 21, 2026
@dmcppcheck
dmcppcheck merged commit 8f7666d into cppcheck-opensource:main Aug 21, 2026
83 of 84 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants