From a38a2a54f72affbb6f8ccec30933f53e5a50005a Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 7 May 2018 05:18:35 -0400 Subject: [PATCH] [locale] Check all XML TimeZone elements if needed - reduce warnings about loop-executed-only-once - if there is more than one TimeZone element, use the virst valid one - warn if nothing is found --- src/modules/locale/GeoIPXML.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/modules/locale/GeoIPXML.cpp b/src/modules/locale/GeoIPXML.cpp index a9aa43f76..0fb5359f3 100644 --- a/src/modules/locale/GeoIPXML.cpp +++ b/src/modules/locale/GeoIPXML.cpp @@ -42,8 +42,14 @@ GeoIPXML::processReply( const QByteArray& data ) for ( int it = 0; it < tzElements.length(); ++it ) { auto e = tzElements.at(it).toElement(); - return splitTZString( e.text() ); + auto tz = splitTZString( e.text() ); + if ( !tz.first.isEmpty() ) + return tz; } + + // None of them valid + cWarning() << "GeopIP XML had no recognizable timezone"; + return qMakePair( QString(), QString() ); } else { @@ -51,5 +57,4 @@ GeoIPXML::processReply( const QByteArray& data ) } return qMakePair( QString(), QString() ); - }