MessageManagerLock freezes Gui

Im trying to build a simple midi sequencer I found on google code but when I´m running it I get this error:


// if component methods are being called from threads other than the message

// thread, you'll need to use a MessageManagerLock object to make sure it's thread-safe.
 ASSERT_MESSAGE_MANAGER_IS_LOCKED

 

and when I add MessageManagerLock like this 

 


void run()
 {

while( ! threadShouldExit() )
 {
  MessageManagerLock mmLock;

//Rest of the code here

}

}

 

the gui freezes any ideas?

thanks for your help 

 

Now I understand the problem is that I`m calling button.setColour(TextButton::buttonColourId, Colours::white); in the Thread, any solution?

void run()
{
  while( ! threadShouldExit() )
  {
    if (buttonColourShouldBeChanged) // If you don't want to set the colour in every loop.
    {
      MessageManagerLock mmLock;
      button.setColour(...)
    }
//Rest of the code here
  }
}

Using MessageManagerLock like that will mostly work but it can still deadlock - please read the comments for that class carefully!

A much more efficient way to do it would be to send a CallbackMessage that makes the change you need.