[Interest] QNetworkAccessManager
Igor Mironchik
igor.mironchik at gmail.com
Tue Aug 25 19:46:35 CEST 2015
Hi Thiago,
On 25.08.2015 19:08, Thiago Macieira wrote:
> 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.
Is it possible to set QT_FATAL_WARNINGS=1 in QtCreator and start debugging?
>
> 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.
>
--
Best Regards,
Igor Mironchik.
More information about the Interest
mailing list