BK8
June 22, 2014, 11:43pm
1
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
BK8
June 22, 2014, 11:54pm
2
Now I understand the problem is that I`m calling button.setColour(TextButton::buttonColourId, Colours::white); in the Thread, any solution?
ckk
June 23, 2014, 5:34am
3
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
}
}
jules
June 23, 2014, 10:31am
4
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.