Skip to content

Commit

Permalink
Server: Fix --serverinfo country code misinterpretation on Qt6
Browse files Browse the repository at this point in the history
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
  • Loading branch information
hoffie committed Aug 30, 2022
1 parent 03f2c30 commit c6d1cb4
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/serverlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<QLocale::Country> ( 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 );
}
}

Expand Down

0 comments on commit c6d1cb4

Please sign in to comment.