[Qt-interest] QHttp (and propably event loop) on OS X (Qt 4.4.3)

sebastian richter richter at fhtw-berlin.de
Tue Mar 3 15:43:26 CET 2009


Hi,

based on my Windows application, i converted that to an xcode project. 
Most things run fine, but i have problems with QHttp. However, the 
things are a bit complicated due to threading, i'll try to explain:

I have basically a GUI main thread and a worker thread. The worker 
thread sleeps as long as the main thread has no work to do. Inside the 
worker thread, i have a function which is used to download data from the 
net (basically, xml data from the yahoo image search api v1). In this 
function, a dispatcher thread is started. This is a QThread derivate. In 
turn, this dispatcher creates several childs loader threads which 
download the (xml) data and read it. These are QThread derivates, too. A 
loader threads run() member sets up a QTimer for single shot to 
implement a timeout and connects a slot to the timers timeout() signal. 
It creates a QHttp, connects the requestStarted(), requestFinished(), 
stateChanged() and done() signals to slots (the first three just for 
debugging), calls setHost() and get() on the QHttp instance and calls 
exec() to run the event loop. Either the slot connected to the 
QHttp::done() ore the one connected to the QTimer::timeout() calls 
exit() to stop the event loop. If a loader finishes without error, the 
dispatcher starts it again if more data is to be downloaded.

This works fine on XP and is quite fast.

However, on OS X this doesn't work at all. The first QHttp request in 
the loader threads (which is QHttp::setHost()) even never starts, thus 
the timeout is fired.

I have build some qDebug() and some additional slots into my code, 
here's the output on XP of a loader:

loader run() : setHostId :  1          // id returned by QHttp::setHost()
loader run() : getId :  2                 // id returned by QHttp::get()
requestStarted() : id : 1
requestFinished() : id : 1
requestFinished() : bool : false
requestStarted() : id : 2
stateChanged() : state :  2
stateChanged() : state :  3
stateChanged() : state :  4
stateChanged() : state :  6
stateChanged() : state :  0
requestFinished() : id : 2
requestFinished() : bool : false

Seems to be ok...
Here's what i get on OS X:

loader run() : setHostId :  1          // id returned by QHttp::setHost()
loader run() : getId :  2                 // id returned by QHttp::get()

That's it. No requestStarted() signal is ever emitted, thus no of my 
slots called, but the event loop finishes when the tiemout is fired.

Any ideas? (I wrote a simple example based on the Qt Http Client example 
code to download the xml data on OS X, this worked fine...)

Regards,

Sebastian




More information about the Qt-interest-old mailing list