[Interest] QCoreApplication::arguments(): getting the application name safely during global destruction
René J.V. Bertin
rjvbertin at gmail.com
Mon Jan 20 13:48:41 CET 2020
Hi,
I call
QString arg0 = qApp? qApp->arguments()[0] : QString();
in order to get the application name in a function that can also be called during the global destruction phase. I've never seen issues with that with Qt <= 5.9 but just had a crash with Qt 5.12.6 :
#6 0x00007f5e8f133dfa in strlen () from /lib/x86_64-linux-gnu/libc.so.6
#7 0x00007f5e8ff0ffe7 in QCoreApplication::arguments() () from /opt/local/libexec/qt512/lib/libQt5Core.so.5
#8 0x00007f5e735479d6 in QtCurve::Style::disconnectDBus (this=0x3813bd0) at /home/bertin/cworks/Scratch/KDE/QtCurve/QtCurve-git/qt5/style/qtcurve.cpp:794
#9 0x00007f5e735483a5 in QtCurve::Style::~Style (this=0x3813bd0) at /home/bertin/cworks/Scratch/KDE/QtCurve/QtCurve-git/qt5/style/qtcurve.cpp:815
#10 0x00007f5e735486f9 in QtCurve::Style::~Style (this=0x3813bd0) at /home/bertin/cworks/Scratch/KDE/QtCurve/QtCurve-git/qt5/style/qtcurve.cpp:813
#11 0x00007f5e735800ac in QtCurve::StylePlugin::~StylePlugin (this=0x37f4eb0) at /home/bertin/cworks/Scratch/KDE/QtCurve/QtCurve-git/qt5/style/qtcurve_plugin.cpp:164
#12 0x00007f5e735801f9 in QtCurve::StylePlugin::~StylePlugin (this=0x37f4eb0) at /home/bertin/cworks/Scratch/KDE/QtCurve/QtCurve-git/qt5/style/qtcurve_plugin.cpp:155
#13 0x00007f5e8ff01094 in QLibraryPrivate::unload(QLibraryPrivate::UnloadFlag) () from /opt/local/libexec/qt512/lib/libQt5Core.so.5
#14 0x00007f5e8fefacb6 in QFactoryLoaderPrivate::~QFactoryLoaderPrivate() () from /opt/local/libexec/qt512/lib/libQt5Core.so.5
#15 0x00007f5e8fefaf09 in QFactoryLoaderPrivate::~QFactoryLoaderPrivate() () from /opt/local/libexec/qt512/lib/libQt5Core.so.5
#16 0x00007f5e8ff368b7 in QObject::~QObject() () from /opt/local/libexec/qt512/lib/libQt5Core.so.5
#17 0x00007f5e8fefc328 in QFactoryLoader::~QFactoryLoader() () from /opt/local/libexec/qt512/lib/libQt5Core.so.5
#18 0x00007f5e90cd65f6 in (anonymous namespace)::Q_QGS_loader::innerFunction()::Holder::~Holder() () from /opt/local/libexec/qt512/lib/libQt5Widgets.so.5
#19 0x00007f5e8f0e71a9 in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#20 0x00007f5e8f0e71f5 in exit () from /lib/x86_64-linux-gnu/libc.so.6
#21 0x00007f5e8f0ccf4c in __libc_start_main () from /lib/x86_64-linux-gnu/libc.so.6
#22 0x00000000007cfef3 in _start () at /usr/include/c++/v1/list:758
Regardless of whether this is a regression in QCoreApplication, is there a safe and cross-platform way to get at the app name in code that might be called as above?
Thanks,
R.
More information about the Interest
mailing list