mirror of
https://gitlab.com/Syping/luaengineapp.git
synced 2024-12-22 20:05:30 +01:00
reworked executeProcess command
This commit is contained in:
parent
f67f3c0365
commit
2879ae33ed
1 changed files with 25 additions and 34 deletions
|
@ -39,44 +39,35 @@ 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);
|
QStringList processArguments;
|
||||||
QVariant lastArgument = arguments.last();
|
QString processPath = getVariant(L_p, 1).toString();
|
||||||
if (lastArgument.type() == QVariant::Bool) {
|
QVariant argument = getVariant(L_p, 2);
|
||||||
runInBackground = lastArgument.toBool();
|
if ((QMetaType::Type)argument.type() == QMetaType::QVariantMap) {
|
||||||
arguments.removeLast();
|
QVariantMap argumentMap = argument.toMap();
|
||||||
|
QVariantMap::const_iterator it = argumentMap.constBegin();
|
||||||
|
QVariantMap::const_iterator end = argumentMap.constEnd();
|
||||||
|
while (it != end) {
|
||||||
|
processArguments << it.value().toString();
|
||||||
|
it++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (arguments.length() >= 2) {
|
else if (argument.type() == QVariant::Bool) {
|
||||||
QStringList processArguments;
|
runInBackground = argument.toBool();
|
||||||
QString processPath = arguments.first().toString();
|
|
||||||
arguments.removeFirst();
|
|
||||||
for (const QVariant &argument : arguments) {
|
|
||||||
if ((QMetaType::Type)argument.type() == QMetaType::QVariantMap) {
|
|
||||||
QVariantMap argumentMap = argument.toMap();
|
|
||||||
QVariantMap::const_iterator it = argumentMap.constBegin();
|
|
||||||
QVariantMap::const_iterator end = argumentMap.constEnd();
|
|
||||||
while (it != end) {
|
|
||||||
processArguments << it.value().toString();
|
|
||||||
it++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
processArguments << argument.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (runInBackground) {
|
|
||||||
processSuccessed = QProcess::startDetached(processPath, processArguments);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
processReturn = QProcess::execute(processPath, processArguments);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (runInBackground) {
|
processArguments << argument.toString();
|
||||||
processSuccessed = QProcess::startDetached(arguments.first().toString());
|
}
|
||||||
}
|
if (getArgumentCount(L_p) >= 3) {
|
||||||
else {
|
if (argument.type() == QVariant::Bool) {
|
||||||
processReturn = QProcess::execute(arguments.first().toString());
|
processArguments << argument.toString();
|
||||||
}
|
}
|
||||||
|
runInBackground = getVariant(L_p, 3).toBool();
|
||||||
|
}
|
||||||
|
if (runInBackground) {
|
||||||
|
processSuccessed = QProcess::startDetached(processPath, processArguments);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
processReturn = QProcess::execute(processPath, processArguments);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
Loading…
Reference in a new issue