Repository navigation
BUG: Fix iterator copy and PathIterator::Value() bugs, and test iterator access - #7135
Conversation
8a2fce5 to
9229cb6
Compare
|
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
|
[Medium impact] The PR appears safe to merge, with no new actionable issues found.
|
9229cb6 to
93654f9
Compare
|
@greptileai review |
93654f9 to
8ea32bc
Compare
|
Force-push |
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.
8ea32bc to
3ad2c2a
Compare
dzenanz
left a comment
There was a problem hiding this comment.
Changes look good on a glance. I have not taken a real look at the tests.
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.