NOISSUE implement more error handling

This commit is contained in:
Joona 2017-08-22 18:35:10 -07:00
parent 6e25624623
commit 59b681a174
No known key found for this signature in database
GPG Key ID: 36D6F8F3E794F2A0

View File

@ -40,34 +40,42 @@ void PrintInstanceInfo::executeTask()
int gpuline = -1; int gpuline = -1;
int cline = 0; int cline = 0;
FILE *fp = popen("lspci -k", "r"); FILE *fp = popen("lspci -k", "r");
while (fgets(buff, 512, fp) != NULL) if (fp != NULL)
{ {
std::string str(buff); while (fgets(buff, 512, fp) != NULL)
if (str.substr(8, 3) == "VGA")
{ {
gpuline = cline; std::string str(buff);
QStringList glines = (QStringList() << QString::fromStdString(str.substr(35, std::string::npos))); if (str.length() < 9)
logLines(glines, MessageLevel::MultiMC); continue;
} if (str.substr(8, 3) == "VGA")
if (gpuline > -1 && gpuline != cline)
{
if (cline - gpuline < 3)
{ {
QStringList alines = (QStringList() << QString::fromStdString(str.substr(1, std::string::npos))); gpuline = cline;
logLines(alines, MessageLevel::MultiMC); QStringList glines = (QStringList() << QString::fromStdString(str.substr(35, std::string::npos)));
logLines(glines, MessageLevel::MultiMC);
} }
if (gpuline > -1 && gpuline != cline)
{
if (cline - gpuline < 3)
{
QStringList alines = (QStringList() << QString::fromStdString(str.substr(1, std::string::npos)));
logLines(alines, MessageLevel::MultiMC);
}
}
cline++;
} }
cline++;
} }
FILE *fp2 = popen("glxinfo", "r"); FILE *fp2 = popen("glxinfo", "r");
while (fgets(buff, 512, fp2) != NULL) if (fp2 != NULL)
{ {
if (strncmp(buff, "OpenGL version string:", 22) == 0) while (fgets(buff, 512, fp2) != NULL)
{ {
QStringList drlines = (QStringList() << QString::fromUtf8(buff)); if (strncmp(buff, "OpenGL version string:", 22) == 0)
logLines(drlines, MessageLevel::MultiMC); {
break; QStringList drlines = (QStringList() << QString::fromUtf8(buff));
logLines(drlines, MessageLevel::MultiMC);
break;
}
} }
} }
#endif #endif