mirror of
https://gitlab.com/Syping/luaengineapp.git
synced 2024-11-05 05:26:55 +01:00
reworked executeProcess command
This commit is contained in:
parent
f67f3c0365
commit
2879ae33ed
1 changed files with 25 additions and 34 deletions
|
@ -39,17 +39,9 @@ int LuaEngineOS::executeProcess(lua_State *L_p)
|
||||||
bool runInBackground = false;
|
bool runInBackground = false;
|
||||||
bool processSuccessed = false;
|
bool processSuccessed = false;
|
||||||
if (getArgumentCount(L_p) >= 2) {
|
if (getArgumentCount(L_p) >= 2) {
|
||||||
QVariantList arguments = getArguments(L_p);
|
|
||||||
QVariant lastArgument = arguments.last();
|
|
||||||
if (lastArgument.type() == QVariant::Bool) {
|
|
||||||
runInBackground = lastArgument.toBool();
|
|
||||||
arguments.removeLast();
|
|
||||||
}
|
|
||||||
if (arguments.length() >= 2) {
|
|
||||||
QStringList processArguments;
|
QStringList processArguments;
|
||||||
QString processPath = arguments.first().toString();
|
QString processPath = getVariant(L_p, 1).toString();
|
||||||
arguments.removeFirst();
|
QVariant argument = getVariant(L_p, 2);
|
||||||
for (const QVariant &argument : arguments) {
|
|
||||||
if ((QMetaType::Type)argument.type() == QMetaType::QVariantMap) {
|
if ((QMetaType::Type)argument.type() == QMetaType::QVariantMap) {
|
||||||
QVariantMap argumentMap = argument.toMap();
|
QVariantMap argumentMap = argument.toMap();
|
||||||
QVariantMap::const_iterator it = argumentMap.constBegin();
|
QVariantMap::const_iterator it = argumentMap.constBegin();
|
||||||
|
@ -59,9 +51,17 @@ int LuaEngineOS::executeProcess(lua_State *L_p)
|
||||||
it++;
|
it++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (argument.type() == QVariant::Bool) {
|
||||||
|
runInBackground = argument.toBool();
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
processArguments << argument.toString();
|
processArguments << argument.toString();
|
||||||
}
|
}
|
||||||
|
if (getArgumentCount(L_p) >= 3) {
|
||||||
|
if (argument.type() == QVariant::Bool) {
|
||||||
|
processArguments << argument.toString();
|
||||||
|
}
|
||||||
|
runInBackground = getVariant(L_p, 3).toBool();
|
||||||
}
|
}
|
||||||
if (runInBackground) {
|
if (runInBackground) {
|
||||||
processSuccessed = QProcess::startDetached(processPath, processArguments);
|
processSuccessed = QProcess::startDetached(processPath, processArguments);
|
||||||
|
@ -70,15 +70,6 @@ int LuaEngineOS::executeProcess(lua_State *L_p)
|
||||||
processReturn = QProcess::execute(processPath, processArguments);
|
processReturn = QProcess::execute(processPath, processArguments);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
if (runInBackground) {
|
|
||||||
processSuccessed = QProcess::startDetached(arguments.first().toString());
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
processReturn = QProcess::execute(arguments.first().toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
processReturn = QProcess::execute(getVariant(L_p, 1).toString());
|
processReturn = QProcess::execute(getVariant(L_p, 1).toString());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue