Value objects that wrap variants holding primitive types,
valueChanged() gets called for listeners when the value changes. E.g. if a
Value wraps an integer and its value changes from
valueChanged() of course is called accordingly.
Values that wrap
valueChanged() is only called if the array object changes. This is because in
VariantType_Array::equals() we have:
auto* thisArray = toArray (data); auto* otherArray = otherType.toArray (otherData); return thisArray == otherArray ...
Here the array pointers are compared. So, if the contents or the array are changed, then
valueChanged() is not called. (To me it seems more intuitive that
Array::operator==() would get used for the comparison here, in which case we would get an elementwise comparison, and
valueChanged() would be called for element changes.)
Options for solutions I can think of are:
- Always set array Values using a new var object and then check in valueChanged() if the array really changed or not (e.g. by storing a previousValue) [Ugly, inefficient]
- Write wrappers around ValueTree and Value that use
Array::operator==()for array comparisons
- Implement a mechanism for notifying of array Value changes that exists outside of Value / ValueTree
Does anyone else view this as a problem and / or have ideas for solutions?