Hi, 8/25/2015 7:08 PM, Thiago Macieira пишет: > On Tuesday 25 August 2015 08:54:35 Igor Mironchik wrote: >> Hi guys, >> >> I created QNetworkAccessManager in a thread. Everything is fine but >> sometimes I received assertion that QCoreApplication can't send event to >> QNetworkAccessManager in another thread. >> >> Is it Qt's bug? Or QnetwrokAccessManager couldn't be used in threaded >> environment? > It's most likely a bug in your code. Please provide the backtrace of the > warning (run your application with QT_FATAL_WARNINGS=1) and we can help find > where you've made a threading mistake.
You was right. It was a bug. Problem is that that QNetworkAccessManager and his QNetworkReply was destroyed in context of another thread. > > QNetworkAccessManager can be used in a thread. But note that *all* uses of it > and the QNetworkReply objects it creates need to be in that thread. You cannot > access any of those objects from outside the thread. So you must have slots in > that thread that do the reading from QNetworkReply and then pass on the > QByteArray to the original thread. > > With that in mind, I have to say: there's no advantage of using threads. > You're just making your code more complex. You'll gain more by removing the > threading. > >> Is it possible to disable sending events from QCoreApplication to my >> network access manager? > No, it is not. The events in question are timer and socket activation events. > If you disable them, QNetworkAccessManager will not receive anything from the > network. > _______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest