Message is never delivered



I'm having a hard time implementing notifications to the GUI thread.

On AAX setStateInformation is called from a thread other then the GUI one. So after loading all the data I have to tell the GUI to load this.

At first I tried to use MessageManager::callFunctionOnMethodThread() but it deadlocked on message->finished.wait(). Then I tried to inherit from MessageListener in the MyAudioProcessorEditor and use postMessage. But the message is never passed to handleMessage(). I figured out that the same is true for callFunctionOnMethodThread(), the code passed in there is just never reached.

To complete my confusion we have a simple UpdateCheckerThread that just pulls a XML file and checks for updates. When an update is found it uses MessageManager::callFunctionOnMethodThread() to show a pop-up informing the user.

So why is one working and the other one isn't? What am I making wrong here?


Thanks in advance

My guess would be that you've just made a typo or some basic error like sending it to the wrong place, deleting the receiver before it arrives, etc.

I made a small test plugin. It just tries to call a function on the editor itself. 

void MessageTestAudioProcessor::setStateInformation (const void* data, int sizeInBytes) {     // You should use this method to restore your parameters from this memory block,     // whose contents will have been created by the getStateInformation() call.     

struct call_data {    
    MessageTestAudioProcessorEditor* myObject;     
    void* myData; 
void* callbackFunction(void* data) {
     call_data* myData = (call_data*)data;
     return myData->myObject->callbackFunctionOnObject(data); 

void MessageTestAudioProcessorEditor::callOnGuiThread() {     
    call_data* myData = new call_data();
    myData->myObject = this;
    MessageManager::getInstance()->callFunctionOnMessageThread(&callbackFunction, myData); 

void* MessageTestAudioProcessorEditor::callbackFunctionOnObject(void* data) {
     DBG("reached GUI Thread");
     return nullptr; 

This simple example completely freezes Pro Tools 11. callFunctionOnMessageThread will never return an the callbackFunction will never be reached. 


Here is the sourcecode to the example I made:

Same applies if you use MessageListener and try calling it from within setStateInformation()

Ok, well callFunctionOnMessageThread is a total non-starter in this situation - if you read the comments for it you'll see the warnings about it causing deadlocks, and since in a plugin you have no control over the context in which it gets called, you really can't use it safely. Personally I don't even use it in an application, because it's so easy to make a mistake and cause a deadlock.

Posting a message should work though, as messages are used all over the place, and if they failed then no plugins would ever work at all. That's what I was talking about when I said you'd probably just made a basic mistake.

Well, you were right, I shouldn't have overloaded the callback method on the message. It is working fine now, thanks!