I’m trying to find a way to programmatically control creating a juce window and I’m having trouble. Everything works fine when the calls to construct / initialize the window are in the same thread as I run MessageManager::runDispatchLoop() but when I move either the dispatch loop or the calls to construct / initialize the window to another thread I’m running into what I think is deadlock. I’ve added what I think are the appropriate calls to construct MessageManagerLock objects but no dice. When I leave the MessageManagerLock objects out, a bunch of asserts fire, but the window works as I expect.
In the attached files (meant to end up in juce/extras/multithread), SimpleWindow::Initialize in SimpleWindow.cc has one line of code that seems to cause the deadlock. It’s the first
const juce::MessageManagerLock mmLock; there. WIth that commented out, lots of asserts fire, but things work. With that code live, I get what I think is deadlock.
I could use a hand diagnosing this. I can think of two ways to get this to happen all in one thread:
- use runDispatchLoopUntil and make sure the programmatic control is via some non-blocking method (not my case at the moment unfortunately)
- use MessageManager::callFunctionOnMessageThread. This works for me and is probably sufficient but I’m curious why I need to do it.
Thanks for any help you can offer.