BUG: Remove redundant m_Threader shadow in MatchCardinalityImageToImageMetric#6257
Merged
hjmjohnson merged 1 commit intoMay 12, 2026
Conversation
…geMetric MatchCardinalityImageToImageMetric redeclared m_Threader that shadows ImageToImageMetric's protected m_Threader. The base's constructor already initializes m_Threader to MultiThreaderBase::New() identical to the subclass's intended default, so the shadow was purely redundant. Update GetMultiThreader to qualify with this-> and rely on the inherited member.
Member
Author
|
@greptile review |
This comment was marked as resolved.
This comment was marked as resolved.
dzenanz
approved these changes
May 12, 2026
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.
Remove
MatchCardinalityImageToImageMetric's redundantm_Threadershadow. The baseImageToImageMetricconstructor already initializes its protectedm_ThreadertoMultiThreaderBase::New()— identical to the subclass's intended default — so the subclass redeclaration served no purpose.The shadow and why it was 100% redundant
itkMatchCardinalityImageToImageMetric.h:189declared (inprivate:):MultiThreaderBase::Pointer m_Threader{ MultiThreaderBase::New() };itkImageToImageMetric.h:632declares (inprotected:):MultiThreaderBase::Pointer m_Threader{};The base's in-class init produces a null pointer, but the base's constructor (
itkImageToImageMetric.hxx) initializes the field in its member-initializer list:So when a
MatchCardinalityImageToImageMetricis constructed, the base constructor runs first and setsm_Threaderto a freshMultiThreaderBase::New(). Then the subclass's in-class init for its shadow runs and ALSO produces a freshNew(). Two threaders allocated; only the subclass's shadow is reachable via the subclass'sGetMultiThreader(). The base's threader is orphaned.The fix
m_Threaderredeclaration inMatchCardinalityImageToImageMetric'sprivate:section.GetMultiThreader()accessor withthis->so the lookup resolves to the inherited protected member:return this->m_Threader;.No constructor change is needed because the base already initializes the field.
Net diff: 4 lines removed, 1 line modified.
Local verification
pre-commit run --all-filespasses.ninja ITKRegistrationCommonHeaderTest1 ITKRegistrationCommonHeaderTest2builds clean.itkMatchCardinalityImageToImageMetricTestCTest: pre-existing baseline failure on this machine (missingSpots.pngExternalData fixture) — verified to fail identically onupstream/mainHEAD without my change. Not a regression from this PR.No new GTest was added because the shadow removal is byte-equivalent (base ctor produces the same
New()pointer the subclass's shadow used to allocate). The single existing public accessor (GetMultiThreader) is exercised by the existing test driver.