Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1369,6 +1369,10 @@ QLocale::Country CLocale::WireFormatCountryCodeToQtCountry ( unsigned short iCou
#if QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 )
// The Jamulus protocol wire format gives us Qt5 country IDs.
// Qt6 changed those IDs, so we have to convert back:
if ( iCountryCode >= qt6CountryToWireFormatLen )
{
return QLocale::AnyCountry;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What should we return otherwise?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There doesn't seem to exist any better alternative than this.

}
return (QLocale::Country) wireFormatToQt6Table[iCountryCode];
#else
return (QLocale::Country) iCountryCode;
Expand All @@ -1380,7 +1384,13 @@ unsigned short CLocale::QtCountryToWireFormatCountryCode ( const QLocale::Countr
#if QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 )
// The Jamulus protocol wire format expects Qt5 country IDs.
// Qt6 changed those IDs, so we have to convert back:
return qt6CountryToWireFormat[(unsigned short) eCountry];
const unsigned short iIdx = static_cast<unsigned short> ( eCountry );

if ( iIdx >= qt6CountryToWireFormatLen )
{
return 0;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what to return...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is correct, because it is the Qt5 value for QLocale::AnyCountry, which is sent on the wire if a country is explicitly not defined.

If a server does not specify --serverinfo, or leaves the country code blank, such as --serverinfo 'My Server;London;', then it gets replaced by the country of the system locale. If the server operator doesn't want a country to show (and there are a small number like that), they need explicitly to give a code of 0: --serverinfo 'My Server;;0'

}
return qt6CountryToWireFormat[iIdx];
#else
return (unsigned short) eCountry;
#endif
Expand Down
Loading