mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-26 02:35:38 +08:00
Ref T304, array index fix if "7za.exe" is not available
This commit is contained in:
@@ -174,7 +174,7 @@ namespace BlackGui
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const CStatusMessage msg = CStatusMessage(this, CLogCategory::validation()).warning("Unzip failed: stdout '%1' stderr '%2'") << stdOutAndError[0] << stdOutAndError[1];
|
const CStatusMessage msg = CStatusMessage(this, CLogCategory::validation()).warning("Unzip failed: stdout '%1' stderr '%2'") << safeAt(stdOutAndError, 0) << safeAt(stdOutAndError, 1);
|
||||||
this->showOverlayMessage(msg);
|
this->showOverlayMessage(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -83,11 +83,29 @@ namespace BlackMisc
|
|||||||
const bool win = CBuildConfig::isRunningOnWindowsNtPlatform();
|
const bool win = CBuildConfig::isRunningOnWindowsNtPlatform();
|
||||||
if (!win) { return CCompressUtils::whichZip7(stdOutAndError); }
|
if (!win) { return CCompressUtils::whichZip7(stdOutAndError); }
|
||||||
|
|
||||||
|
// windows check
|
||||||
QStringList args;
|
QStringList args;
|
||||||
args << "i";
|
args << "i";
|
||||||
QProcess zipProcess;
|
QProcess zipProcess;
|
||||||
zipProcess.start("7za.exe", args);
|
zipProcess.start("7za.exe", args);
|
||||||
const bool finished = zipProcess.waitForFinished();
|
const bool finished = zipProcess.waitForFinished();
|
||||||
|
if (stdOutAndError)
|
||||||
|
{
|
||||||
|
stdOutAndError->clear();
|
||||||
|
const QString pStdout = zipProcess.readAllStandardOutput();
|
||||||
|
const QString pStderr = zipProcess.readAllStandardError();
|
||||||
|
if (pStdout.isEmpty() && pStderr.isEmpty())
|
||||||
|
{
|
||||||
|
stdOutAndError->push_back("Checking 7za");
|
||||||
|
stdOutAndError->push_back("No 7za or failing");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
stdOutAndError->push_back(pStdout);
|
||||||
|
stdOutAndError->push_back(pStderr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (zipProcess.exitStatus() != QProcess::NormalExit) { return false; }
|
if (zipProcess.exitStatus() != QProcess::NormalExit) { return false; }
|
||||||
if (!finished) { return false; }
|
if (!finished) { return false; }
|
||||||
const int r = zipProcess.exitCode();
|
const int r = zipProcess.exitCode();
|
||||||
|
|||||||
@@ -108,6 +108,14 @@ namespace BlackMisc
|
|||||||
return s.trimmed();
|
return s.trimmed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Safe "at" function, returns empty string if index does not exists
|
||||||
|
inline const QString &safeAt(const QStringList &stringList, int index)
|
||||||
|
{
|
||||||
|
if (stringList.size() > index) { return stringList.at(index); }
|
||||||
|
static const QString empty;
|
||||||
|
return empty;
|
||||||
|
}
|
||||||
|
|
||||||
//! String with digits only
|
//! String with digits only
|
||||||
inline bool isDigitsOnlyString(const QString &testString)
|
inline bool isDigitsOnlyString(const QString &testString)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user