valueChanged not being called for Value::Listener


#1

I have a simple class as follows:

class Thing : public Value::Listener
{
public:
    Thing();

    void process();

    void valueChanged(Value &value) override;

private:
    Value x;
    Value y;
    Value z;

    JUCE_LEAK_DETECTOR(Thing)

};

using namespace std;

Thing::Thing()
{
    x = 100.0;
    y = 200.0;
    z = 100.0;

    x.addListener(this);
    y.addListener(this);
    z.addListener(this);
}

void Thing::valueChanged(Value &value)
{
    if (value.refersToSameSourceAs(x))
    {
        cout << "value x changed" << endl;
    }
    else if (value.refersToSameSourceAs(y))
    {
        cout << "value y changed" << endl;
    }
    else if (value.refersToSameSourceAs(z))
    {
        cout << "value z changed" << endl;
    }
}

void Thing::process()
{
    x = 99.0;
    y = 101.0;
    z = -1000.0;
}

The problem I'm seeing is when I do the following:

Thing thing;

thing.process();

I don't see the valueChanged function being called. My other issue is how I distinguish between different Values in valueChanged? Is refersToSameSourceAs the right way?