Interesting. This may explain some of our interesting QTimer issues too... So it seems I don't know enough about Qt to help here. Hopefully Albert or someone will have an idea.
Adam On 04/03/2008, Wesley S. <[EMAIL PROTECTED]> wrote: > 2008/3/4, Adam Davison <[EMAIL PROTECTED]>: > > Hi Wesley, > > > > This is more Qt wierdness I think than multi-threading specifically. I > > assume your problem is that QTcpSocket is going to call back to your > > code at some point using slots and signals. This shouldn't be a > > problem because the event loop is running globally throughout the > > whole application. The only thing you do need to be careful of is that > > any of your code which is triggered by those callbacks will probably > > be running inside the event handler which means that if it takes a > > long time you're delaying processing of user interface events and so > > on. > > > > Or if your problem is really something else then I'm sure we can solve > > that too :) > > > > What I gather from this page - > http://doc.trolltech.com/4.3/threads.html - is that it's > not so simple (I think). > > Some quotes from that page: > > * Event driven objects may only be used in a single thread. Specifically, > this applies to the timer mechanism and the network module. For example, you > cannot start a timer or connect a socket in a thread that is not the > object's thread. > * An event loop in a thread makes it possible for the thread to use certain > non-GUI Qt classes that require the presence of an event loop (such as > QTimer, QTcpSocket, and QProcess). > > If I just try and create a (subclassed) QTcpSocket in the constructor of > the EngineShoutcast and call QTcpSocket::connectToHost() I will _never_ > receive the connected() signal because there is no event loop in the thread > it is running in (if I put in some qApp->processEvents() it works around > that problem, but of course that is not clean and doesn't always work) > > Furthermore, this happens after the (subclassed) QTcpSocket object is > destroyed: > ASSERT failure in QCoreApplication::sendEvent: "Cannot send events to > objects owned by a different thread. Current thread 839a0b0. Receiver '' (of > type 'QAbstractSocket') was created in thread 8448ab0", file > kernel/qcoreapplication.cpp > It does not happen if I don't call QTcpSocket::connectToHost(). > -- > Wesley Stessens <[EMAIL PROTECTED]> > Human Knowledge Belongs To The World - Antitrust (2001) > http://wesley.debianbox.be ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ Mixxx-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mixxx-devel
