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

Mårten Nordheim marten.nordheim at qt.io
Tue Feb 4 17:14:44 CET 2020


It’s likely related to the new network connection monitor inside QNetworkAccessManager, which uses COM.
Although that by itself shouldn’t cause any issues and there’s other uses of COM inside Qt as well. But perhaps you didn’t indirectly use it so you didn’t get a conflict earlier.
I suppose it was bound to conflict with something sooner or later ;(

Apologies for the inconvenience!


From: maitai<mailto:maitai at virtual-winds.org>
Sent: tirsdag 4. februar 2020 17:08
To: Interest at qt-project.org<mailto:Interest at qt-project.org>
Subject: Re: [Interest] Crash when creating QNetworkAccessManager in qt 5.14.x

Thanks Robert and Thiago,

If I create it on the stack instead of on the heap same mystery, i.e if
I create it before qApp all good, if after it crashes

this works:
     QNetworkAccessManager inet;
     qWarning()<<"after test";
     QApplication app(argc, argv);

this crashes:
     QApplication app(argc, argv);
     QNetworkAccessManager inet;
     qWarning()<<"after test";

Interesting is that in that last case I have a new message in the

Failed to initialize COM library.  Error code = 0x -7ffefefa, before my
"test" qWarning()...

Googling it tells me it's about using WMI and it's true I do have some
WMI functions defined statically in an object.

Still that was working fine before 5.14.0 (5.13.2 for instance), and why
creating/deleting it before qApp fixes it all is beyond my level of

Philippe Lelong.

Le 04-02-2020 16:43, Thiago Macieira a écrit :
> On Tuesday, 4 February 2020 01:45:27 PST coroberti . wrote:
>> Sorry, I meant allocation of QNetworkAccessManager object
>> by new operator (dynamic) versus its allocation on function scope
>> (static).
> Instead of static, please use automatic storage (no static, no new).
> Create it
> in the stack, after QApplication.
Interest mailing list
Interest at qt-project.org

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20200204/9ae1e96a/attachment.html>

More information about the Interest mailing list