summaryrefslogtreecommitdiffstats
path: root/src/corelib/time
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2024-02-09 13:56:52 +0100
committerEdward Welbourne <edward.welbourne@qt.io>2024-02-28 19:50:20 +0100
commitec9ca7ac43cfebc74afc03de338f81a879354b2a (patch)
treef740528920c23fb71c71392cdd990d1f9259a26b /src/corelib/time
parentc738a349d2d6fa27e994657ce38fe9027c96a251 (diff)
Also check available in TZ timezone's constructor
Follow up to commit 00d9a9a9b59650b8e297f91dcc600c377da5bceb - as commented in the QTZ constructor, one of the reasons for the prior "is available" check was to avoid creating TZ cache entries for it; so have the TZ backend also (like ICU) overtly check for availability before trying to find data for the given ID. This duplicates work done later in the constructor, which can perhaps be optimised out later, but is no worse than where we were before the commit mentioned above. Pick-to: 6.7 6.6 6.5 Task-number: QTBUG-121807 Change-Id: Ie0571df2de2bf0a3f4ee767184e58b378e8cb05a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/time')
-rw-r--r--src/corelib/time/qtimezone.cpp1
-rw-r--r--src/corelib/time/qtimezoneprivate_tz.cpp2
2 files changed, 2 insertions, 1 deletions
diff --git a/src/corelib/time/qtimezone.cpp b/src/corelib/time/qtimezone.cpp
index 00d0d3a79e..a5eaa56931 100644
--- a/src/corelib/time/qtimezone.cpp
+++ b/src/corelib/time/qtimezone.cpp
@@ -459,7 +459,6 @@ QTimeZone::QTimeZone(const QByteArray &ianaId)
d = newBackendTimeZone();
else // Constructor MUST produce invalid for unsupported ID.
d = newBackendTimeZone(ianaId);
- // else: No such ID, avoid creating a TZ cache entry for it.
}
// Can also handle UTC with arbitrary (valid) offset, but only do so as
// fall-back, since either of the above may handle it more informatively.
diff --git a/src/corelib/time/qtimezoneprivate_tz.cpp b/src/corelib/time/qtimezoneprivate_tz.cpp
index f4a2df00a4..afa7cf0370 100644
--- a/src/corelib/time/qtimezoneprivate_tz.cpp
+++ b/src/corelib/time/qtimezoneprivate_tz.cpp
@@ -998,6 +998,8 @@ QTzTimeZoneCacheEntry QTzTimeZoneCache::fetchEntry(const QByteArray &ianaId)
// Create a named time zone
QTzTimeZonePrivate::QTzTimeZonePrivate(const QByteArray &ianaId)
{
+ if (!isTimeZoneIdAvailable(ianaId)) // Avoid pointlessly creating cache entries
+ return;
static QTzTimeZoneCache tzCache;
auto entry = tzCache.fetchEntry(ianaId);
if (entry.m_tranTimes.isEmpty() && entry.m_posixRule.isEmpty())