STYLE: Remove unused m_UserSpecifiedImageIO from writers#6648
Conversation
|
I investigated the failing job and the first fatal error is a compile break in ImageSeriesWriter::PrintSelf. Error points to Modules/IO/ImageBase/include/itkImageSeriesWriter.hxx (around line ~348), where a PrintSelf macro expands to m_UserSpecifiedImageIO, but that member no longer exists: Recommended fix: update PrintSelf to stop referencing the removed/renamed ivar. Remove itkPrintSelfBooleanMacro(UserSpecifiedImageIO); This should unblock the failing compile target: This is only the first failure, possible others. |
The member was declared in ImageFileWriter and ImageSeriesWriter but never read or written in their implementations.
a8f1a11 to
1f7421a
Compare
|
Fixed the compilation error by removing |
|
Just wondering, why was |
|
| Filename | Overview |
|---|---|
| Modules/IO/ImageBase/include/itkImageFileWriter.h | Removes an unused private Boolean member without changing writer behavior. |
| Modules/IO/ImageBase/include/itkImageSeriesWriter.h | Removes the unused protected image-I/O tracking member. |
| Modules/IO/ImageBase/include/itkImageSeriesWriter.hxx | Removes the matching Boolean field from PrintSelf output. |
Reviews (2): Last reviewed commit: "STYLE: Remove unused m_UserSpecifiedImag..." | Re-trigger Greptile
|
@N-Dekker It was used in On @greptile-apps' open issue (protected-member removal breaking external subclasses): I searched a downstream testbed of 31 ITK-consumer source trees built against ITK main — no consumers of the removed member, and no subclasses of Where the logic actually lives (answers "why was it added")
// itkImageFileReader.hxx:67 (SetImageIO)
m_UserSpecifiedImageIO = true;
// itkImageFileReader.hxx:100 (GenerateOutputInformation)
if (m_UserSpecifiedImageIO == false) // try creating via factory
{
m_ImageIO = ImageIOFactory::CreateImageIO(this->GetFileName().c_str(), ReadMode);
}
// itkImageFileWriter.h:234
bool m_FactorySpecifiedImageIO{ false }; // did factory mechanism set the ImageIO?
// itkImageFileWriter.h:139 (SetImageIO)
m_FactorySpecifiedImageIO = false;
// itkImageFileWriter.hxx:99
if (m_ImageIO.IsNull() || (m_FactorySpecifiedImageIO && !m_ImageIO->CanWriteFile(m_FileName.c_str())))
{
m_ImageIO = ImageIOFactory::CreateImageIO(m_FileName.c_str(), WriteMode);
m_FactorySpecifiedImageIO = true; // hxx:112
}The writer's form is the stronger of the two: it re-runs the factory when a factory-made IO (Line numbers from ITK main @ 0acef9a.) Downstream search: method and resultCorpus: 31 ITK-consumer source trees checked out and built against ITK main in a downstream build testbed — ANTs, elastix, Slicer, BRAINSTools, SimpleITK, RTK, MITK, and the ITK remote modules.
Caveat: 31 consumers is not the whole ecosystem; a private or unlisted downstream subclass of Possibly out of scope: ImageSeriesWriter has no provenance flag at all
|
|
@blowekamp In its current state, this is dead code (or at least not fully gestated code). I think removing it is the correct choice. I did wonder if making it symmetric with the itkImageFileReader made sense. Still, given the 20-year history of being a copy-and-paste addition, I don't think there is a compelling need to add the requisite logic to keep this alive. |
Remove the
m_UserSpecifiedImageIOmember fromImageFileWriterandImageSeriesWriter. The member was declared in both classes but never read or written in their implementations (itkImageFileWriter.hxx/itkImageSeriesWriter.hxx).AI assistance
GitHub Copilot (Claude Sonnet 4.6) identified the unused members via workspace-wide grep, verified no usages existed in the implementation files, removed the declarations, and committed the change.