forked from qt-creator/qt-creator
PluginSpec platform: More deterministic name for Linux
There is not even a guarantee that VERSION from os-release contains "Linux" anywhere. Prepend "Linux" or "Unix" and add the version details in parentheses instead. Also remove unnecessary (and wrong) /etc/issues fallback. Change-Id: I0457ad9e8cedeea35e0cad5ea8093652eb8428e1 Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
@@ -1382,6 +1382,12 @@ static inline QString getPlatformName()
|
||||
result += QLatin1String(" 10.") + QString::number(QSysInfo::MacintoshVersion - QSysInfo::MV_10_0);
|
||||
return result;
|
||||
#elif defined(Q_OS_UNIX)
|
||||
QString base;
|
||||
# ifdef Q_OS_LINUX
|
||||
base = QLatin1String("Linux");
|
||||
# else
|
||||
base = QLatin1String("Unix");
|
||||
# endif // Q_OS_LINUX
|
||||
QFile osReleaseFile(QLatin1String("/etc/os-release")); // Newer Linuxes
|
||||
if (osReleaseFile.open(QIODevice::ReadOnly)) {
|
||||
QString name;
|
||||
@@ -1398,22 +1404,10 @@ static inline QString getPlatformName()
|
||||
if (!name.isEmpty()) {
|
||||
if (!version.isEmpty())
|
||||
name += QLatin1Char(' ') + version;
|
||||
return name;
|
||||
return base + QLatin1String(" (") + name + QLatin1Char(')');
|
||||
}
|
||||
}
|
||||
QFile issueFile(QLatin1String("/etc/issue")); // Older Linuxes
|
||||
if (issueFile.open(QIODevice::ReadOnly)) {
|
||||
QByteArray issue = issueFile.readAll();
|
||||
const int end = issue.lastIndexOf(" \\n");
|
||||
if (end >= 0)
|
||||
issue.truncate(end);
|
||||
return QString::fromLatin1(issue).trimmed();
|
||||
}
|
||||
# ifdef Q_OS_LINUX
|
||||
return QLatin1String("Linux");
|
||||
# else
|
||||
return QLatin1String("Unix");
|
||||
# endif // Q_OS_LINUX
|
||||
return base;
|
||||
#elif defined(Q_OS_WIN)
|
||||
QString result = QLatin1String("Windows");
|
||||
switch (QSysInfo::WindowsVersion) {
|
||||
|
||||
Reference in New Issue
Block a user