qt-interest@trolltech.com
[Top] [All Lists]

Re: [Qt-interest] Running Qt in a child thread on OSX fails; suggestions

Subject: Re: [Qt-interest] Running Qt in a child thread on OSX fails; suggestions?
From: Michael Jackson
Date: Wed, 09 Jun 2010 14:10:15 -0400
On 6/9/10 1:55 PM, in article 4C0FD5AD.6090508@xxxxxxxxxxxxxxxxxx, "Penn
Taylor" wrote:

> 
> 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();

If I remember correctly the GUI thread MUST be the FIRST thread on OS X.
Other toolkits have dealt with these issues also. QtCarbon might be more
forgiving than QtCocoa but I am not sure about that either.

Mike Jackson

_______________________________________________
Qt-interest mailing list
Qt-interest@xxxxxxxxxxxxx
http://lists.trolltech.com/mailman/listinfo/qt-interest

<Prev in Thread] Current Thread [Next in Thread>