Wow dude… I think I figured it out! Well how to reproduce it. My multithreaded app creates a CallbackMessage from a background thread and posts it. This causes one of my Components to call repaint() from the message thread. When I start the operation that creates repeated CallbackMessages, the drag image stops functioning. When this background operation completes, and the CallbackMessages stop coming in, the drag image magically starts working / appears (even while I am in the middle of a non-functioning drag, if the background operation finishes, the drag image suddenly appears during the mouseDown / mouseDrag gesture).
Now the crappy part is that during audio playback, I am continually creating CallbackMessage from my audio thread to inform the Gui to repaint various Components like level meters and all that good stuff. So of course, the drag image is completely broken during audio playback.
This only happens when allowDraggingToOtherJuceWindows == true.
So here is my code that processes the CallbackMessage:
// CallbackMessage posted to Ui / message thread that processes all asychronous
// operations on the Ui thread via m_queue.Process();
struct ProcessThreadQueueCallbackMessage : CallbackMessage
ProcessThreadQueueCallbackMessage (Vf::ThreadQueue& queue)
: m_queue (queue)
// Called from various threads to signal the Ui ThreadQueue to process
ProcessThreadQueueCallbackMessage* m =
new ProcessThreadQueueCallbackMessage (m_uiThreadQueue);
And here is an example of a function that might be called during m_queue.Process()
repaint(); // just redraw everything
Here is my sequence of operations that makes the drag image (when allowDraggingToOtherJuceWindows==true, always the case for ListBox):
- Start a background thread operation
- Background thread operation is continuously generating CallbackMessages from another thread
- CallbackMessages get processed on the Ui thread, leading to repeated calls to AudioDataView::onMoreDataAvailable()
- While these CallbackMessages are happening, the drag image does not appear
- As soon as the background thread stops generating CallbackMessages, the drag image pops into view / works