mirror of
https://github.com/nicbarker/clay.git
synced 2025-04-15 10:48:04 +00:00
Copy elementId in Clay__AddHashMapItem() in case underlying stringId has moved
If the string reference passed to an element id has changed between frames (e.g. moved), then the reference stored in the hash item can become stale. This change makes sure that we're always using the latest value.
This commit is contained in:
parent
5fae7a6249
commit
3a3815ebc8
1
clay.h
1
clay.h
@ -1189,6 +1189,7 @@ Clay_LayoutElementHashMapItem* Clay__AddHashMapItem(Clay_ElementId elementId, Cl
|
||||
if (hashItem->elementId.id == elementId.id) { // Collision - resolve based on generation
|
||||
item.nextIndex = hashItem->nextIndex;
|
||||
if (hashItem->generation <= context->generation) { // First collision - assume this is the "same" element
|
||||
hashItem->elementId = elementId; // Make sure to copy this across. If the stringId reference has changed, we should update the hash item to use the new one.
|
||||
hashItem->generation = context->generation + 1;
|
||||
hashItem->layoutElement = layoutElement;
|
||||
hashItem->debugData->collision = false;
|
||||
|
Loading…
Reference in New Issue
Block a user