Skip to content

Commit

Permalink
Suppress warnings about deprecated QString constructor
Browse files Browse the repository at this point in the history
They were introduced in commit c416a7f.

 warning: ‘QString::QString(const QByteArray&)’ is deprecated: Use fromUtf8, QStringLiteral, or QLatin1String [-Wdeprecated-declarations]

Change-Id: I6a540578e810472bb455fffd1532e31736e1edc9
Reviewed-by: Edward Welbourne <[email protected]>
  • Loading branch information
thiagomacieira committed May 30, 2018
1 parent 9ffb001 commit b9dc4f7
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/corelib/tools/qlocale_unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ Q_GLOBAL_STATIC(QSystemLocaleData, qSystemLocaleData)

#ifndef QT_NO_SYSTEMLOCALE

static bool contradicts(const QByteArray &maybe, const QByteArray &known)
static bool contradicts(const QString &maybe, const QString &known)
{
if (maybe.isEmpty())
return false;
Expand Down Expand Up @@ -137,25 +137,25 @@ static bool contradicts(const QByteArray &maybe, const QByteArray &known)
QLocale QSystemLocale::fallbackUiLocale() const
{
// See man 7 locale for precedence - LC_ALL beats LC_MESSAGES beats LANG:
QByteArray lang = qgetenv("LC_ALL");
QString lang = qEnvironmentVariable("LC_ALL");
if (lang.isEmpty())
lang = qgetenv("LC_MESSAGES");
lang = qEnvironmentVariable("LC_MESSAGES");
if (lang.isEmpty())
lang = qgetenv("LANG");
lang = qEnvironmentVariable("LANG");
// if the locale is the "C" locale, then we can return the language we found here:
if (lang.isEmpty() || lang == QByteArray("C") || lang == QByteArray("POSIX"))
return QLocale(QString::fromLatin1(lang));
if (lang.isEmpty() || lang == QLatin1String("C") || lang == QLatin1String("POSIX"))
return QLocale(lang);

// ... otherwise, if the first part of LANGUAGE says more than or
// contradicts what we have, use that:
QByteArray language = qgetenv("LANGUAGE");
QString language = qEnvironmentVariable("LANGUAGE");
if (!language.isEmpty()) {
language = language.split(':').constFirst();
language = language.split(QLatin1Char(':')).constFirst();
if (contradicts(language, lang))
return QLocale(QString::fromLatin1(language));
return QLocale(language);
}

return QLocale(QString::fromLatin1(lang));
return QLocale(lang);
}

QVariant QSystemLocale::query(QueryType type, QVariant in) const
Expand Down

0 comments on commit b9dc4f7

Please sign in to comment.