From 8af874010890f42af93197b1cc01fbb98f98f404 Mon Sep 17 00:00:00 2001 From: Christian Hoffmann Date: Tue, 30 Aug 2022 22:00:08 +0200 Subject: [PATCH] Server: Fix --serverinfo country code misinterpretation on Qt6 Previously, country codes in --serverinfo were interpreted natively. This worked for Qt5, but caused unintended changes on Qt6 builds as the codes differ. Not doing a conversion for --serverinfo was an oversight from the initial Qt6 compatibility work, which is now fixed with this change. Related: #2299 Fixes: #2809 --- src/serverlist.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/serverlist.cpp b/src/serverlist.cpp index ac0db51706..1f1aa5b53d 100644 --- a/src/serverlist.cpp +++ b/src/serverlist.cpp @@ -205,9 +205,15 @@ CServerListManager::CServerListManager ( const quint16 iNPortNum, // [this server country as QLocale ID] bool ok; const int iCountry = slServInfoSeparateParams[2].toInt ( &ok ); - if ( ok && iCountry >= 0 && iCountry <= QLocale::LastCountry ) + if ( ok && iCountry >= 0 && CLocale::IsCountryCodeSupported ( iCountry ) ) { - ThisServerListEntry.eCountry = static_cast ( iCountry ); + // Convert from externally-supplied format ("wire format", Qt5 codes) to + // native format. On Qt5 builds, this is a noop, on Qt6 builds, a conversion + // takes place. + // We try to do such conversions at the outer-most interface which is capable of doing it. + // Although the value comes from src/main -> src/server, this very place is + // the first where we have access to the parsed country code: + ThisServerListEntry.eCountry = CLocale::WireFormatCountryCodeToQtCountry ( iCountry ); } }