diff options
author | David Faure <david.faure@kdab.com> | 2015-02-22 19:35:43 +0100 |
---|---|---|
committer | David Faure <david.faure@kdab.com> | 2015-03-05 10:29:27 +0000 |
commit | 6c973dee2cb1686ea32657fff7dced3e611b98ce (patch) | |
tree | 5fb6dc6546349b38a62f1f4f396808f6b0626196 /tests | |
parent | dce3721f90eb7179df6f91d27614adfb29059b65 (diff) |
Make QCoreApplication::applicationName available after app destruction.
Calling applicationName() in the destructor of a global static (e.g.
via QLockFile) was working when calling setApplicationName explicitly
but otherwise it would suddenly return an empty string.
This led to inconsistencies, the application name switching from
non-empty to empty at saving-on-destruction time.
There was already a global static, used when setting the app name
explicitly before construction. Use it now to store the app name
in all cases (explicitly set, or fallback).
Change-Id: I71d3a0c40158f8bfd022c385b198346a2594b1cb
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp index 93a6daa6b9..ff4963a960 100644 --- a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp +++ b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp @@ -102,10 +102,15 @@ void tst_QCoreApplication::qAppName() const char* appName = "tst_qcoreapplication"; #endif - int argc = 1; - char *argv[] = { const_cast<char*>(appName) }; - TestApplication app(argc, argv); - QCOMPARE(::qAppName(), QString::fromLatin1(appName)); + { + int argc = 1; + char *argv[] = { const_cast<char*>(appName) }; + TestApplication app(argc, argv); + QCOMPARE(::qAppName(), QString::fromLatin1(appName)); + QCOMPARE(QCoreApplication::applicationName(), QString::fromLatin1(appName)); + } + // The application name should still be available after destruction; + // global statics often rely on this. QCOMPARE(QCoreApplication::applicationName(), QString::fromLatin1(appName)); } |