[Qt-interest] Running Qt in a child thread on OSX fails; suggestions?
Penn Taylor
penn.taylor at atdeconsulting.com
Wed Jun 9 19:55:57 CEST 2010
Summary:
Running Qt in a child thread on OSX fails, but works fine on GNU/Linux.
Why? And what can be done to make this work?
Details:
My application starts up a Qt "application" in a child thread; that is,
NOT in the primordial thread. The main entry point, event loop, etc. for
the Qt application are all started up in this same child thread. I'm
using a non-Qt parent application (vrjuggler), so no QThreads are
explicitly involved. This strategy works fine on GNU/Linux (using both
Qt 4.6.0 and 4.6.3), but on Mac OSX (Qt 4.6.1) I'm getting the following
warnings before the program seg faults:
QCoreApplication::sendPostedEvents: Cannot send posted events for
objects in another thread
QCoreApplication::sendPostedEvents: Cannot send posted events for
objects in another thread
QPixmap: It is not safe to use pixmaps outside the GUI thread
QPixmap: It is not safe to use pixmaps outside the GUI thread
I've researched these and dealt with them before on Linux, but I'm
baffled why this fails on OSX. Everything *is* happening in the GUI
Thread, it just happens that the GUI Thread is not the primordial
thread. The QCoreApplication::sendPostedEvents warning is only given
when the sending thread and receiving thread do not match, but in this
case they *should* match because all Qt events are happening in the same
child thread.
Any clues as to what is going on here? Is there some subtlety to Mac's
threading model that causes Qt to get a different thread identifier when
it looks at the same child thread twice?
To replicate this issue, just fire off the following code in a child
thread of some multi-threaded non-Qt application:
QApplication a( argc, argv );
QPushButton aButton("Test");
aButton.show();
a.exec();
More information about the Qt-interest-old
mailing list