fix: fixed windows startup issue

This commit is contained in:
Qv2ray-Bot 2020-01-24 14:55:21 +08:00
parent 4de6ac4354
commit 9cf41b84ab
2 changed files with 19 additions and 4 deletions

View File

@ -1 +1 @@
3088
3095

View File

@ -66,7 +66,16 @@ namespace Qv2ray
// Check if V2ray core returns a version number correctly.
QProcess proc;
proc.start(vCorePath + " -version");
#ifdef Q_OS_WIN32
// nativeArguments are required for Windows platform, without a reason...
proc.setProcessChannelMode(QProcess::MergedChannels);
proc.setProgram(vCorePath);
proc.setNativeArguments("--version");
proc.start();
#else
proc.start(vCorePath + " --version");
#endif
proc.waitForStarted();
proc.waitForFinished();
auto exitCode = proc.exitCode();
@ -76,8 +85,14 @@ namespace Qv2ray
return false;
}
QString output = QString(proc.readAllStandardOutput());
QString output = proc.readAllStandardOutput();
LOG(MODULE_VCORE, "V2ray output: " + SplitLines(output).join(";"))
if (SplitLines(output).isEmpty()) {
*message = tr("V2ray core returns empty string.");
return false;
}
*message = SplitLines(output).first();
return true;
}
@ -118,7 +133,7 @@ namespace Qv2ray
V2rayKernelInstance::V2rayKernelInstance()
{
vProcess = new QProcess();;
vProcess = new QProcess();
connect(vProcess, &QProcess::readyReadStandardOutput, this, [this]() {
emit onProcessOutputReadyRead(vProcess->readAllStandardOutput().trimmed());
});