[Interest] Image Updates Aren't Painting

Jared McIntyre Jared.McIntyre at medsimulation.com
Wed Jul 9 23:52:26 CEST 2014


We've recently migrated from Qt 5.1 to 5.3.1 and have run into a problem where none of the 2D imaging updates on change. For example, when a QGraphicsPixmapItem is updated with a new image, it continues to display the old image until another QWidget is overlaid on top of that item and then removed (note that merely dragging another window over this window does not cause the image to refresh). This issue effects all images including those loaded inside of a webkit control. I have attempted to force paint calls on several widgets in different ways and to the root window itself, but the only ways I've found to refresh is to add a widget on top and then to remove that widget or to hide and then show the widget again.

I've determined that this is somehow caused by how we use QGLWidgets and possibly threads. We're doing some complicated things with OpenGL that might be gumming up the works on this new vesion of Qt.

1) We have multiple QGLWidgets and threads.
2) The context for each rendered QGLWidget is created on the main thread, but the ownership of the context is shifted out to a render thread using the code:
	m_pGLWidget->doneCurrent();
	m_pGLWidget->context()->moveToThread( m_pThreadData->m_newThread );
The context is then made current on the new render thread and future swapBuffer calls are called on the render thread instead of the main thread.
3) All contexts are shared.
4) Auto buffer swap is disabled.
5) There is an additional parentless QGLWidget that is hidden from view and never drawn to. Instead, the context of that widget is used by the main thread to perform certain opengl management functions that better run in preparation before the render thread takes over. swapBuffer is never called on this context, but it is regularly flushed. This widget is still created even in the scenario that I described earlier that works and 2D images update (only the widgets with contexts on separate threads were removed).

If I never create the QGLWidgets and their threaded contexts, all 2D imaging works correctly. In this case, the non-parented QGLWidget is still being created and OpenGL calls were still being made against to.

It is an odd setup, but it has worked since Qt 4.7 and only had to make adjustments in 5 to deal with the thread moving restrictions for qt managed gl contexts. Does anyone have ideas of areas I can look into? Also, if there are any sections of code that would be helpful for me to post, please let me know. I'm at a bit of a loss on where to continue the debugging.

Here is some additional information on my setup:

OpenGL build of Qt 5.3.1 (OpenGL 3.2 configured for use by our contexts)
Visual Studio 2013
Windows 7

Thanks,

Jared McIntyre



More information about the Interest mailing list