Make AIList resilient against invalidating iterators.
This adds a counter and a 'dead' flag to the data stored in the linked list. The counter counts the number of iterators (still) pointing to an element and the dead flag is set to indicate the element was erased when iterators are still pointing to it. As a result, iterators are NEVER invalidated. Of course, such elements are subsequentially skipped when iterating over the list. Assertions protect against dereferencing an erased iterator, but incrementing or decremention still works: it is still well-defined what the next (non erased) element is, assuming the element wasn't erased (yet), but would be erased delayed - or assuming the iterator would have been incremented (decremented) in advance to erasing the element.
This commit is contained in:
@@ -101,7 +101,7 @@ public:
|
||||
// Used for sorting
|
||||
struct sort
|
||||
{
|
||||
bool operator()(const LLView* i1, const LLView* i2)
|
||||
bool operator()(const LLView* i1, const LLView* i2) const
|
||||
{
|
||||
LLTextureBar* bar1p = (LLTextureBar*)i1;
|
||||
LLTextureBar* bar2p = (LLTextureBar*)i2;
|
||||
@@ -120,7 +120,7 @@ public:
|
||||
|
||||
struct sort_fetch
|
||||
{
|
||||
bool operator()(const LLView* i1, const LLView* i2)
|
||||
bool operator()(const LLView* i1, const LLView* i2) const
|
||||
{
|
||||
LLTextureBar* bar1p = (LLTextureBar*)i1;
|
||||
LLTextureBar* bar2p = (LLTextureBar*)i2;
|
||||
|
||||
Reference in New Issue
Block a user