Skip to content

add()ing an element twice can result in bugs with element sorting #120

Closed
@anderoonies

Description

@anderoonies

Describe the bug
Consider the following elementPool, where elements marked with o are .alive = true, x are .alive = false, and the vertical bar | represents elementPoolSize:

> add(a)
> add(b)
> add(c)
> add(a)

  o  o  o  o
[ a, b, c, a | ]

> remove(a)

  x  o  o  x
[ a, b, c, a | ]

// internal resort during redraw
// counts 2 deleted elements

  o  o   x  x
[ b, c | a, a ]

> add(a)

// increments elementPoolSize by 1

  o  o  o   o
[ b, c, a | a ]

> a.layer = 0

// internal resort during redraw

  o  o  o   o
[ a, a, b | c ]

// poor c :(

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions