template <typename Type>
inline void CachedValue<Type>::setValue (const Type& newValue, UndoManager* undoManagerToUse)
{
if (cachedValue != newValue || isUsingDefault())
{
cachedValue = newValue;
targetTree.setProperty (targetProperty, VariantConverter<Type>::toVar (newValue), undoManagerToUse);
}
}
template <typename Type>
inline void CachedValue<Type>::resetToDefault (UndoManager* undoManagerToUse)
{
targetTree.removeProperty (targetProperty, undoManagerToUse);
forceUpdateOfCachedValue();
}
With setValue
it updates the cached value and then calls all the listeners. With resetToDefault
it calls all the listeners and then updates the cached value.
So, if in your listener of the tree, you access the CachedValue
, you will get outdated values.
I think it should be:
template <typename Type>
inline void CachedValue<Type>::resetToDefault (UndoManager* undoManagerToUse)
{
cachedValue = defaultValue;
targetTree.removeProperty (targetProperty, undoManagerToUse);
}