Problem
The RowEntityDropdown template function in editor/src/ImNexo/Components.hpp has a critical design flaw with its static variable caching mechanism. The static variables for caching (entityNamePairs, lastTargetEntity, lastEntities) are instantiated separately for each template instantiation, but more critically, they assume global state which breaks when the same template instantiation is used in different contexts with different entity lists.
Impact
When two different UI components use RowEntityDropdown with the same GetNameFunc type but different entity lists, they incorrectly share the same cache, leading to wrong entity names being displayed.
Suggested Solutions
- Remove caching entirely if performance is acceptable
- Pass a cache object as a parameter that the caller manages
- Use a more sophisticated caching key that includes the entity list identity
- Redesign the function interface to avoid shared state issues
References
Problem
The
RowEntityDropdowntemplate function ineditor/src/ImNexo/Components.hpphas a critical design flaw with its static variable caching mechanism. The static variables for caching (entityNamePairs,lastTargetEntity,lastEntities) are instantiated separately for each template instantiation, but more critically, they assume global state which breaks when the same template instantiation is used in different contexts with different entity lists.Impact
When two different UI components use
RowEntityDropdownwith the sameGetNameFunctype but different entity lists, they incorrectly share the same cache, leading to wrong entity names being displayed.Suggested Solutions
References