Qt Threading Issues in Linux
-
Hello,
I have been developing with Qt for some time now on my project, and we are starting to move to a more thread-oriented design. Upon moving some GL rendering widgets to other threads I have discovered some very weird behavior. It appears that if a GL Widget begins updating from another thread (boost thread or QThread) before a widget that accepts user input (such as a QTextEdit) grabs focus, I get XCB crashes that look like:
[xcb] Too much data requested from _XRead
[xcb] This is most likely caused by a broken X extension library
[xcb] Aborting, sorry about that.
hypnotizer: ../../src/xcb_io.c:735: _XRead: Assertion '!xcb_xlib_too_much_data_requested' failed.To test this out, I actually can make a simple modification to the GLHypnotizer demo to reproduce the crash. That demo can be found here: "http://qt-project.org/doc/qt-4.8/demos-glhypnotizer.html":http://qt-project.org/doc/qt-4.8/demos-glhypnotizer.html
If I add the line 'mdiArea.addSubWindow(new QTextEdit(this));' at around line 313 (before the call to newThread()), then when the demo starts there will be a QTextEdit and a GL Hypnotizer Widget. If I then click on the QTextEdit to grab focus I will get the above crash every time.
Can anyone reproduce the error on there Linux install using the above instructions? Has anyone encountered these types of issues on Linux using Qt and threading before?
Any help would be greatly appreciated!
--Kellen
Note: I am using Ubuntu 12 and this crash happens in VirtualBox and non VirtualBox Ubuntu installations
-
Hi kelano,
all UI stuff must be done in the main thread, not in worker threads. You can prepare the data in a worker thread, but the update itself MUST be done in main.
Might be that you change exactly treats this, as you have a "normal" widget there. If openGL can be rendered in other threads, it might be, I have no experience with OpenGL.
-
I believe he was trying the demo from:
blog.qt.digia.com/2011/06/03/threaded-opengl-in-4-8
and it looks like the QTextWidget is being added from the main thread (from the line number he gave).
I've tried the demo that Qt released, and it works fine on my mac with the added QTextWidget, so maybe it's an X11 bug?