Flawed label structure
Posted: Wed May 23, 2012 5:31 am
After looking more into labels, I realized the code is flawed. The label id corresponds to the size of the array of labels an area has. So for instance, we make 3 labels, each with the id of 1,2,3.
Now we delete label 1, given 2 label ids:2,3.
The next call to create a label will do this: it will return the next label id as 2, the size of the array, and thus overwrite the old label 2 with the new label 2. Additionally, since this is a QMap which has a unique key->value, this will prevent any new labels from being added to the area.
Conveniently, this fixes this:
Now we delete label 1, given 2 label ids:2,3.
The next call to create a label will do this: it will return the next label id as 2, the size of the array, and thus overwrite the old label 2 with the new label 2. Additionally, since this is a QMap which has a unique key->value, this will prevent any new labels from being added to the area.
Conveniently, this fixes this: