summaryrefslogtreecommitdiffstats
path: root/api/logic/minecraft
diff options
context:
space:
mode:
authorJoona <joonatoona@digitalfishfun.com>2017-08-22 18:35:10 -0700
committerJoona <joonatoona@digitalfishfun.com>2017-08-22 18:35:10 -0700
commit59b681a174baa420471064a1a49d821549f48b37 (patch)
tree62795a29925ca77405e60e1172d2d57bf50ba796 /api/logic/minecraft
parent6e25624623b2361ff5874d5d85d4ed3054722b6a (diff)
downloadMultiMC-59b681a174baa420471064a1a49d821549f48b37.tar
MultiMC-59b681a174baa420471064a1a49d821549f48b37.tar.gz
MultiMC-59b681a174baa420471064a1a49d821549f48b37.tar.lz
MultiMC-59b681a174baa420471064a1a49d821549f48b37.tar.xz
MultiMC-59b681a174baa420471064a1a49d821549f48b37.zip
NOISSUE implement more error handling
Diffstat (limited to 'api/logic/minecraft')
-rw-r--r--api/logic/minecraft/launch/PrintInstanceInfo.cpp46
1 files changed, 27 insertions, 19 deletions
diff --git a/api/logic/minecraft/launch/PrintInstanceInfo.cpp b/api/logic/minecraft/launch/PrintInstanceInfo.cpp
index c4474814..6e2657a8 100644
--- a/api/logic/minecraft/launch/PrintInstanceInfo.cpp
+++ b/api/logic/minecraft/launch/PrintInstanceInfo.cpp
@@ -40,34 +40,42 @@ void PrintInstanceInfo::executeTask()
int gpuline = -1;
int cline = 0;
FILE *fp = popen("lspci -k", "r");
- while (fgets(buff, 512, fp) != NULL)
+ if (fp != NULL)
{
- std::string str(buff);
- if (str.substr(8, 3) == "VGA")
+ while (fgets(buff, 512, fp) != NULL)
{
- gpuline = cline;
- QStringList glines = (QStringList() << QString::fromStdString(str.substr(35, std::string::npos)));
- logLines(glines, MessageLevel::MultiMC);
- }
- if (gpuline > -1 && gpuline != cline)
- {
- if (cline - gpuline < 3)
+ std::string str(buff);
+ if (str.length() < 9)
+ continue;
+ if (str.substr(8, 3) == "VGA")
{
- QStringList alines = (QStringList() << QString::fromStdString(str.substr(1, std::string::npos)));
- logLines(alines, MessageLevel::MultiMC);
+ gpuline = cline;
+ 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");
- 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));
- logLines(drlines, MessageLevel::MultiMC);
- break;
+ if (strncmp(buff, "OpenGL version string:", 22) == 0)
+ {
+ QStringList drlines = (QStringList() << QString::fromUtf8(buff));
+ logLines(drlines, MessageLevel::MultiMC);
+ break;
+ }
}
}
#endif