aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2016-11-09 18:27:04 +0100
committerEdward Welbourne <edward.welbourne@qt.io>2017-01-10 18:11:19 +0000
commite7bfab82b45df088d15cbb4c5213ca94e260220d (patch)
tree856ba01a34c86816452b8a20c8bdd1284696f0b2 /tests
parentba244f5400bfff1601cc6b373383b55956fcf6bb (diff)
tst_qqmllocale: use unsetenv to clear environment variable
tst_qqmllocale::timeZoneUpdated() was recording the prior time zone, frobbing it for the duration of its test, then restoring it. However, if TZ was previously unset, it got set to empty instead of being unset. This did not quite have the same effect; UTC ends up being used instead of the system default, with potential for conflict between system functions (that have attended to tzset) and third-party libraries (e.g. ICU) with internal state saved from before the change. Change-Id: I9f2147cd8858316e9ba5fd84d95dfc2c4538b0ab Reviewed-by: Matthew Vogt <matthew.vogt@qinetic.com.au> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/qqmllocale/tst_qqmllocale.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp b/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp
index 44d11cdda3..7a6cb7c929 100644
--- a/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp
+++ b/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp
@@ -1267,7 +1267,10 @@ QString DateFormatter::getLocalizedForm(const QString &isoTimestamp)
// which will require linking to a different library to access that API.
static void setTimeZone(const QByteArray &tz)
{
- qputenv("TZ", tz);
+ if (tz.isEmpty())
+ qunsetenv("TZ");
+ else
+ qputenv("TZ", tz);
::tzset();
// following left for future reference, see comment above