callAsync and base/derived class methods


#1

I have a class which is derived from AudioProcessor. In a thread which is not the message thread, I want to schedule a callback on the message thread like this: MessageManager::callAsync([=]() {this->sendParamChangeMessageToListeners(index, newValue); });
Now what I don’t understand is that, when the actual callback of sendParamChangeMessageToListeners happens, it is done not from an object of my derived class, but from an object of the base class (which means that it will use the wrong number of parameters as I don’t use managedParameters yet). So how can I make sure that in the callback, my derived class’s methods are being called instead of those of the base class?


#2

Maybe try this instead :

MessageManager::callAsync([this]() {sendParamChangeMessageToListeners(index, newValue); });

edit : But probably won’t help, as the “this” object shouldn’t be copyable anyway…(Because of the Juce “not copyable” macro.)


#3

This doesn’t compile as I need to capture index and newValue. Also, the this pointer is captured correctly, i.e. when setting a breakpoint in sendParamChangeMessageToListeners, the object on which it is called has the correct address in memory, it’s just that it is interpreted as an AudioProcessor* at that point.


#4

What happens if you dynamic_cast this to a pointer of your class?

Rail


#5

No change…