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

maitai maitai at virtual-winds.org
Tue Feb 4 17:06:12 CET 2020


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:
     qWarning()<<"test";
     QNetworkAccessManager inet;
     qWarning()<<"after test";
     QApplication app(argc, argv);

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

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

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 
understanding...

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.


More information about the Interest mailing list