Add buttons to FileInfo to automatically add missing include files#57
Open
mroda88 wants to merge 2 commits into
Open
Add buttons to FileInfo to automatically add missing include files#57mroda88 wants to merge 2 commits into
mroda88 wants to merge 2 commits into
Conversation
MRiganSUSX
reviewed
Jun 9, 2026
MRiganSUSX
left a comment
There was a problem hiding this comment.
Thanks for this change @gcrone, very good idea.
Comments:
- exception safety
insrc/structure/FileInfo.cpp:add_includefile,add_missing_schemafiles,add_missing_datafiles
Manuallym_updatingtoggling is risky. If iefile::add()throws, the flag stays true.
Suggestion is to useQScopedValueRollback, ie:
#include <QScopedValueRollback>
void FileInfo::add_missing_schemafiles() {
QScopedValueRollback<bool> guard(m_updating, true);
auto fname = prune_path(m_filename);
if (s_missing_schema_map.contains(fname)) {
for (const auto& file : s_missing_schema_map.at(fname)) {
config::api::commands::file::add(m_filename, file);
}
}
parse_includes();
parse_objects();
}
- map access
insrc/structure/FileInfo.cppinsideparse_objects()andcheck_file_includes()
.at()can throw out of range if the key is missing
suggested to add a safety check, ie:
auto fname = prune_path(m_filename);
if (s_missing_schema_map.contains(fname)) {
m_ui->add_missing_schema->setVisible(!s_missing_schema_map.at(fname).empty());
}
- map mem leak
ininclude/dbe/FileInfo.*
the maps are not destroyed
the suggestion is to add explicit destructor ie:
- header
~FileInfo();
- cpp
FileInfo::~FileInfo() {
auto fname = prune_path(m_filename);
s_missing_schema_map.erase(fname);
s_missing_data_map.erase(fname);
s_obj_map.erase(fname);
}
more generally, any reason the map objects (s_obj_map, s_missing_schema_map, s_missing_data_map) are static instead of standard non-static private members?
- path comparison
insrc/structure/FileInfo.cppinsidematch_path()
same as in OKS,.endsWith()relies heavily on proper naming and can cause false positives.
suggested to useQFileInfo:
#include <QFileInfo>
bool FileInfo::match_path(const QString& file, const QString& top_file, const QStringList& includes) {
// Compare file names instead of full path strings
if (QFileInfo(top_file).fileName() == QFileInfo(file).fileName()) {
return true;
}
|
I understand some of these have nothing to do with the PR changes. |
Contributor
|
To answer the comments above:
|
…ueRollback for m_updating variable
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
See CCM meeting https://indico.fnal.gov/event/74797/
Changes can be validate running DBE. Change an object in a file that has missing includes and see that the new buttons are functional.

Type of change
Testing checklist
dbt-build --unittest)pytest -s minimal_system_quick_test.py)dunedaq_integtest_bundle.sh)python -m pytest)pre-commit run --all-files)Comments here on the testing
Further checks
dbt-build --lint, and/or see https://dune-daq-sw.readthedocs.io/en/latest/packages/styleguide/)(Indicate issue here: # (issue))