ValueSource change messages


#1

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?


#2

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]


#3

naturally, that also works :slight_smile: