ValueSource change messages

I’ve a case where I need to respond to a Value change by repopulating a group of Values. One of those values happens to be the one that has changed - this means that the value source can get freed whilst inside sendChangeMessage.

The boring fix is to make my thingamabob an AsyncUpdater, and only rebuild after the change has finished.

However, the more seamless fix is to just inc/dec the reference count before/after the synchronous message is sent within ValueSource::sendChangeMessage. Is that something you wouldn’t mind adding?

Excellent idea. I guess it’d just be this:

[code]void Value::ValueSource::sendChangeMessage (const bool synchronous)
{
if (synchronous)
{
const ReferenceCountedObjectPtr localRef (this);

    for (int i = valuesWithListeners.size(); --i >= 0;)

…[/code]

naturally, that also works :slight_smile: