QMetaObject::invokeMethod with Qt::BlockingQueuedConnection from render thread
-
Hi,
I have a
QQuickFramebufferObjectwhere I would like to call an external rendering function (written in Julia). Because Julia is not thread-safe, the rendering function must be called from the main thread. The easiest solution is to just setQSG_RENDER_LOOPtobasic, but that is easy to forget and sub-optimal for other components in the scene graph.Looking at the scene graph documentation, I thought it would have been possible to call back into the main thread using
QMetaObject::invokeMethodwith aQt::BlockingQueuedConnectionfrom withinQQuickFramebufferObject::Renderer::render, but this seems to result in a deadlock. Using just aQt::QueuedConnectiondoesn't work either, because then the rendering function gets called after the context is invalidated.It seems that the GUI thread does not continue processing events until
QQuickFramebufferObject::Renderer::renderhas completed, even though the docs state that the GUI thread is unblocked during render? The documentation forQQuickFramebufferObjecteven states: "Using queued connections or events for communication between item and renderer is also possible".Cheers,
Bart
-
I have added a stand-alone test case here:
https://github.com/barche/render-threadsThe problem is at line 18 in fborender.cpp:
https://github.com/barche/render-threads/blob/master/fborender.cpp#L18Is the use of a
Qt::BlockingQueuedConnectionsomehow disallowed here?