GH-4014 fix kernel version scanning on macOS and linux

This commit is contained in:
Petr Mrázek 2021-09-04 22:10:57 +02:00
parent 938f896bfa
commit c17b359d03
2 changed files with 16 additions and 2 deletions

View File

@ -4,6 +4,7 @@
#include <QString> #include <QString>
#include <QStringList> #include <QStringList>
#include <QDebug>
Sys::KernelInfo Sys::getKernelInfo() Sys::KernelInfo Sys::getKernelInfo()
{ {
@ -23,11 +24,17 @@ Sys::KernelInfo Sys::getKernelInfo()
auto sections = release.split('-'); auto sections = release.split('-');
if(sections.size() >= 1) { if(sections.size() >= 1) {
auto versionParts = sections[0].split('.'); auto versionParts = sections[0].split('.');
if(sections.size() >= 3) { if(versionParts.size() >= 3) {
out.kernelMajor = sections[0].toInt(); out.kernelMajor = sections[0].toInt();
out.kernelMinor = sections[1].toInt(); out.kernelMinor = sections[1].toInt();
out.kernelPatch = sections[2].toInt(); out.kernelPatch = sections[2].toInt();
} }
else {
qWarning() << "Not enough version numbers in " << sections[0] << " found " << versionParts.size();
}
}
else {
qWarning() << "Not enough '-' sections in " << release << " found " << sections.size();
} }
return out; return out;
} }

View File

@ -8,6 +8,7 @@
#include <QString> #include <QString>
#include <QStringList> #include <QStringList>
#include <QDebug>
Sys::KernelInfo Sys::getKernelInfo() Sys::KernelInfo Sys::getKernelInfo()
{ {
@ -28,11 +29,17 @@ Sys::KernelInfo Sys::getKernelInfo()
auto sections = release.split('-'); auto sections = release.split('-');
if(sections.size() >= 1) { if(sections.size() >= 1) {
auto versionParts = sections[0].split('.'); auto versionParts = sections[0].split('.');
if(sections.size() >= 3) { if(versionParts.size() >= 3) {
out.kernelMajor = sections[0].toInt(); out.kernelMajor = sections[0].toInt();
out.kernelMinor = sections[1].toInt(); out.kernelMinor = sections[1].toInt();
out.kernelPatch = sections[2].toInt(); out.kernelPatch = sections[2].toInt();
} }
else {
qWarning() << "Not enough version numbers in " << sections[0] << " found " << versionParts.size();
}
}
else {
qWarning() << "Not enough '-' sections in " << release << " found " << sections.size();
} }
return out; return out;
} }