Skip to content

Replace Modified() call in itk::Object, remove Modified() call from BSplineDeformableTransform - #6855

Open
N-Dekker wants to merge 2 commits into
InsightSoftwareConsortium:mainfrom
N-Dekker:Remove-Modified-from-constructors
Open

Replace Modified() call in itk::Object, remove Modified() call from BSplineDeformableTransform#6855
N-Dekker wants to merge 2 commits into
InsightSoftwareConsortium:mainfrom
N-Dekker:Remove-Modified-from-constructors

Conversation

@N-Dekker

@N-Dekker N-Dekker commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

For the record Object::Modified() is defined here:

/**
* Make sure this object's modified time is greater than all others.
*/
void
Object::Modified() const
{
m_MTime.Modified();
InvokeEvent(ModifiedEvent());
}

It appears to have overrides at:

Modules/Core/ImageAdaptors/include/itkImageAdaptor.h
Modules/Filtering/ImageIntensity/include/itkNormalizeImageFilter.h
Modules/Filtering/MathematicalMorphology/include/itkGrayscaleDilateImageFilter.h
Modules/Filtering/MathematicalMorphology/include/itkGrayscaleErodeImageFilter.h
Modules/Filtering/MathematicalMorphology/include/itkGrayscaleMorphologicalClosingImageFilter.h
Modules/Filtering/MathematicalMorphology/include/itkGrayscaleMorphologicalOpeningImageFilter.h
Modules/Filtering/MathematicalMorphology/include/itkMorphologicalGradientImageFilter.h
Modules/Filtering/ParabolicMorphology/include/itkBinaryDilateParabolicImageFilter.h
Modules/Filtering/ParabolicMorphology/include/itkBinaryErodeParabolicImageFilter.h
Modules/Filtering/ParabolicMorphology/include/itkMorphologicalDistanceTransformImageFilter.h
Modules/Filtering/ParabolicMorphology/include/itkParabolicOpenCloseSafeBorderImageFilter.h
Modules/Nonunit/Review/include/itkMiniPipelineSeparableImageFilter.h

Default-constructors usually do not need to call `this->Modified()`. This
particular Modified() call was accidentally moved into the function body of
the default-constructor of BSplineDeformableTransform by
pull request InsightSoftwareConsortium#6854
commit 9953d5f
"STYLE: Remove SetFixedParameters... functions from BSplineBaseTransform"
It appears preferable for the `itk::Object` default-constructor _not_ to call
`this->Modified()`, for two reasons:

 - `Object::Modified()` is virtual, but still the function call will not call
any possible override, as explained by C++ Core Guidelines, "Don’t call virtual
functions in constructors and destructors", Jun 14, 2026,
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#rc-ctor-virtual
 - `Object::Modified()` calls InvokeEvent(ModifiedEvent()), which is useless
when an Object is still "under construction", as it does not yet have any
observer.

So this `itk::Object` constructor should only update its timestamp, m_MTime.
@github-actions github-actions Bot added the area:Core Issues affecting the Core module label Sep 10, 2026

@dzenanz dzenanz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Change is small, and reasoning makes sense. CI can totally sink it, though 😄

@N-Dekker
N-Dekker marked this pull request as ready for review September 10, 2026 13:12
@greptile-apps

greptile-apps Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Summary

  • Initializes object modification timestamps directly during construction and removes a redundant B-spline construction-time modification call.
  • No actionable issues were identified.

T-Rex validation blocked

  • Runtime compilation could not run because the CMake-generated itkConfigure.h header and the CMake/Ninja toolchain are unavailable.

Confidence Score: 5/5

No blocking issues were identified; the change is safe to merge.

The review identified no actionable findings. The attempted before-and-after construction check was blocked equally in both revisions by missing generated build configuration.

Files Needing Attention: No files require changes. Runtime construction behavior can be rechecked once a configured ITK build environment is available.

T-Rex T-Rex Logs

What T-Rex did

  • I compared construction-time modifications between the pre-change and updated revisions and ran the narrow itkObject.cxx compilation check.
  • I observed that both checks halted at the same missing itkConfigure.h header, so runtime construction behavior could not be observed.
  • I authored and executed the pr6855-construction-check.sh script, capturing before, after, and runner outputs.
  • I documented that the construction-check run produced no actionable findings.

View all artifacts

T-Rex Ran code and verified through T-Rex

Reviews (1): Last reviewed commit: "STYLE: Replace Modified() with m_MTime.M..." | Re-trigger Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:Core Issues affecting the Core module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants