Repository navigation
BUG: Fix iterator copy and PathIterator::Value() bugs, and test iterator access - #7135
Draft
hjmjohnson wants to merge 5 commits into
Draft
hjmjohnson wants to merge 5 commits into
hjmjohnson wants to merge 5 commits into
Conversation
RandomPermutation::operator= reallocated its node array but never copied the nodes into it, so every node kept index zero. Copy-assigning an ImageRandomNonRepeatingConstIteratorWithIndex therefore produced an iterator that visited the region's first pixel for every sample. Copy the nodes through a new copy constructor, which also gives the copy its own generator, seeded with the source's seed: the implicit one shared the node array, and sharing the generator let reseeding one permutation change the other's order. The iterator's operator= now copies the sample counters too, so a target that was default-constructed or over another region visits the source's samples. SetPriority rejects an index equal to the size.
…erator The implicit copy constructor of ImageRandomNonRepeatingConstIteratorWithIndex copied the m_Permutation pointer, so the copy and the source shared one permutation and each deleted it. A copy used after the source was destroyed read freed memory. The copy constructor now copies the permutation and the sample counters, as operator= does.
…pies The copy constructor of ReflectiveImageRegionConstIterator rewound the copy to the beginning, and operator= did not copy m_IsFirstPass, so a copy did not continue where the source was. Both now copy the full state; code that relied on a copy starting over calls GoToBegin() on it.
Value() called a GetImage() member and read an m_ImageIndex member that PathIterator does not have, so any call to it failed to compile. It now returns the pixel at m_CurrentImageIndex, as Set() writes it.
Covers, for the current iterator names: which iterators provide Set() and an assignable Value(), one-way conversion from writable to read-only iterators and comparison between them, class template argument deduction from raw image pointers, reverse traversal of a sub-region, reflective iterator copies, and random non-repeating conversions that outlive their source.
hjmjohnson
force-pushed
the
enh-iterator-coverage-tests
branch
from
November 8, 2026 03:10
8a2fce5 to
9229cb6
Compare
Member
Author
|
Force-push What changed (one commit: "ENH: Test image iterator write access, conversions, and copies")
#7065's first five commits are these five again ( Local verification at 9229cb6
|
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.
Fixes two image iterator bugs on
mainand adds tests for the iterators' current write access, conversions, and copies. This splits the fixes and the coverage that does not depend on the rework out of #7065, which will be rebased on this PR.Requires #7068 to merge first: its two commits come first on this branch; review from "BUG: Keep the position and reflection state in reflective iterator copies".
BUG:Copying aReflectiveImageRegionConstIteratorrewound it, andoperator=droppedm_IsFirstPass.BUG:PathIterator::Value()did not compile: it called aGetImage()member and read anm_ImageIndexmember that do not exist.ENH:Tests forSet()andValue()access, one-way conversion from writable to read-only iterators and their comparison, deduction from raw image pointers, reverse traversal of a sub-region, and copies that outlive their source.Local verification
ReverseIteratorConversionCallsNonConstGetBufferPointer.ReflectiveImageRegionIterator.ConversionToConstIteratorKeepsPositionfails;RandomNonRepeatingConversionOutlivesSourcedepends on BUG: Copy the shuffled order when assigning a RandomPermutation #7068's copy constructor.pre-commit run --all-filespasses.Left for #7065
These checks do not hold on
mainand stay with the rework:ImageReverseConstIteratorandImageRegionReverseConstIteratorprovideSet()through aconst_cast;LineConstIterator,PathConstIterator, andReflectiveImageRegionConstIteratorhave no deduction guide; onlyImageIteratorWithIndexhasImageIteratorDimension.