Commit a2f66019 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[FIX #268] colormapper does not crash anymore when sorting two textures....

[FIX #268] colormapper does not crash anymore when sorting two textures. Reason was a invalidated iterator still being used after invalidation.
parent 97ef5c95
......@@ -465,7 +465,7 @@ bool WGEColormapping::moveTo( osg::ref_ptr< WGETexture3D > texture, size_t idx )
}
// after inserting the item somewhere, the index of the original item might change
TextureContainerType::Iterator eraseIdx = iter; // item is inserted behind the current one -> index of the original item stays the same
size_t eraseIdx = iter - w->get().begin(); // item is inserted behind the current one -> index of the original item stays the same
size_t eraseShift = 0;
// if the inserted element is in front of the old one, the old one's index is increasing
if( ( w->get().begin() + idx ) < iter )
......@@ -477,12 +477,11 @@ bool WGEColormapping::moveTo( osg::ref_ptr< WGETexture3D > texture, size_t idx )
// NOTE: this is not the best way to do it. Manually moving items should be better. But as the colormapper has to handle only a small number
// of elements, this is not critical.
w->get().insert( w->get().begin() + idx, texture );
w->get().erase( eraseIdx + eraseShift );
w->get().erase( w->get().begin() + eraseIdx + eraseShift );
// unlock and call callbacks
w.reset();
m_sortSignal();
return true;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment