Re: [Interest] QDateTime::toString() fails when used in exit handler
Il 19/06/20 22:12, Bernhard Lindner ha scritto: Can someone tell me what is going wrong here? There's a wider blanket statement made by Qt: you're not allowed to touch _most_ Qt APIs without a QCoreApplication object being alive. That's the case here. In detail, QDateTime uses some global that got already destroyed by the time your atexit handler runs. But Qt doesn't even guarantee that the usage in main() is OK (because there's no QCA around). My 2 c, -- Giuseppe D'Angelo | giuseppe.dang...@kdab.com | Senior Software Engineer KDAB (France) S.A.S., a KDAB Group company Tel. France +33 (0)4 90 84 08 53, http://www.kdab.com KDAB - The Qt, C++ and OpenGL Experts smime.p7s Description: Firma crittografica S/MIME ___ Interest mailing list Interest@qt-project.org https://lists.qt-project.org/listinfo/interest
Re: [Interest] QDateTime::toString() fails when used in exit handler
On Friday, 19 June 2020 13:12:17 PDT Bernhard Lindner wrote: > Can someone tell me what is going wrong here? Yes, the calendar system in Qt has already been destroyed. You can't format dates anymore. QDateTime::date() and QDateTime::time() still work. In general, don't do anything complex in exit handlers, since most global statics will have been destroyed already. SIOF: Static (De)Initialisation Order Fiasco. -- Thiago Macieira - thiago.macieira (AT) intel.com Software Architect - Intel System Software Products ___ Interest mailing list Interest@qt-project.org https://lists.qt-project.org/listinfo/interest
[Interest] QDateTime::toString() fails when used in exit handler
Hi! I tried to log `std::exit` calls in my GCC10 compiled Qt 5.14.2 application under KDE Neon 18.04. This fails when turning a `QDateTime` object into a string. It can be reproduced with the following snippet: void exitHandler() noexcept { QString b = QDateTime::currentDateTime().toString(); } int main(int pArgc, char* pArgv[]) noexcept { std::atexit(); QString a = QDateTime::currentDateTime().toString(); std::exit(1); return 0; } Variable `a` contains the expected date/time while variable `b` is empty. When using UTC time, `b` is " GMT". I am not aware of any related restrictions of exit-handlers. Can someone tell me what is going wrong here? -- Best Regards, Bernhard Lindner ___ Interest mailing list Interest@qt-project.org https://lists.qt-project.org/listinfo/interest