Hi
I am working on a application launcher and using QProcess to Launch the application. However, QProcess is failing to set the environment.
The application launches without a license.
Here is the version of code.
void MainWindow
::appItemClicked(const QString &appName
) {
QJsonObject jo = getApplicationInfo(appName);
auto joEnv
= jo.
value(QString("env")).
toObject();
auto joBin
= jo.
value(QString("bin")).
toArray();
foreach (auto val, joBin)
args << val.toString();
auto env
= QProcess::systemEnvironment();
foreach (auto key, joEnv.keys())
{
auto newValue = joEnv.value(key).toString();
env.insert(key, newValue);
}
process.setProgram(args[0]);
args.pop_front();
if (args.count() > 0)
process.setArguments(args);
process.setProcessEnvironment(env);
process.startDetached();
process.waitForFinished(-1);
}
void MainWindow::appItemClicked(const QString &appName)
{
QJsonObject jo = getApplicationInfo(appName);
auto joEnv = jo.value(QString("env")).toObject();
auto joBin = jo.value(QString("bin")).toArray();
QStringList args;
foreach (auto val, joBin)
args << val.toString();
auto env = QProcess::systemEnvironment();
foreach (auto key, joEnv.keys())
{
auto newValue = joEnv.value(key).toString();
env.insert(key, newValue);
}
QProcess process;
process.setProgram(args[0]);
args.pop_front();
if (args.count() > 0)
process.setArguments(args);
process.setProcessEnvironment(env);
process.startDetached();
process.waitForFinished(-1);
}
To copy to clipboard, switch view to plain text mode
getApplicationInfo () returns this data
{
"env": {
"FOUNDRY_LOG_FILE": "/Scratch/log/nuke/nuke11.log",
"RLM_LICENSE": "port@ip_address",
},
"bin": [
"/usr/local/Nuke11/Nuke",
"--nukex"
]
}
{
"env": {
"FOUNDRY_LOG_FILE": "/Scratch/log/nuke/nuke11.log",
"RLM_LICENSE": "port@ip_address",
},
"bin": [
"/usr/local/Nuke11/Nuke",
"--nukex"
]
}
To copy to clipboard, switch view to plain text mode
If I run the same in "/bin/bash" the application finds the license and works perfectly.
the shell script looks like this
#!/bin/bash
export FOUNDRY_LOG_FILE=~/software/Scratch/log/nuke/nuke11.log
export RLM_LICENSE=port@ip_address
/usr/local/Nuke11/Nuke --nukex
#!/bin/bash
export FOUNDRY_LOG_FILE=~/software/Scratch/log/nuke/nuke11.log
export RLM_LICENSE=port@ip_address
/usr/local/Nuke11/Nuke --nukex
To copy to clipboard, switch view to plain text mode
Can anyone help find where am I going wrong?
Thanks in advance.
Navin
Bookmarks