From a3a2d3df20a61836c41b9f115b2a8244d4381519 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Fri, 9 Feb 2024 13:56:52 +0100 Subject: [PATCH] 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.6 6.5 Task-number: QTBUG-121807 Change-Id: Ie0571df2de2bf0a3f4ee767184e58b378e8cb05a Reviewed-by: Thiago Macieira (cherry picked from commit ec9ca7ac43cfebc74afc03de338f81a879354b2a) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/time/qtimezoneprivate_tz.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/corelib/time/qtimezoneprivate_tz.cpp b/src/corelib/time/qtimezoneprivate_tz.cpp index c682fc8f70d..dcd518403f6 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())