[Interest] Crash when creating QNetworkAccessManager in qt 5.14.x

Rainer Wiesenfarth rainer_wiesenfarth at trimble.com
Wed Feb 5 11:53:16 CET 2020

That being said, even if I remove this call and all references to WMI code
> and CoInitializeEx (including the links to wbemuuid and ws2_32), it still
> crashes if i do not create QNetworkManager before QApplication...

Our experience is that only the first call to CoInitializeEx() succeeds and
that subsequent calls with a different threading model fail.

That being said, I _assume_ that *both*, QNetworkManager and QApplication
reach a call to CoInitializeEx() somewhere deep down the code (e.g. in a
loaded plugin or even an Explorer extension), and these two calls differ in
the selected threading model. For your application the two cases are:

QNetworkManager before QApplication: QNetworkManager initializes its
desired threading model, the call to CoInitializeEx() in QApplication
fails, but does not cause any harm.

QApplication before QNetworkManager: QApplication initializes its desired
threading model, the call to CoInitializeEx() in QNetworkManager fails and
causes a crash.

To avoid the call to QNetworkManager before QApplication, you should
probably use the /CLRTHREADATTRIBUTE:{MTA,STA,NONE} linker flag (in VS:
Linker - Advanced - CLR Thread Attribute) with the correct value for your

Cheers, Rainer

Software Engineer | Trimble Imaging Division
Rotebühlstraße 81 | 70178 Stuttgart | Germany
Office +49 711 22881 0 | Fax +49 711 22881 11
http://www.trimble.com/imaging/ | http://www.inpho.de/

Trimble Germany GmbH, Am Prime Parc 11, 65479 Raunheim
Eingetragen beim Amtsgericht Darmstadt unter HRB 83893,
Geschäftsführer: Rob Reeder, Jürgen Kesper
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20200205/a8a833da/attachment.html>

More information about the Interest mailing list