Results 1 to 3 of 3

Thread: QProcess setEnvirontment fails

  1. #1
    Join Date
    Apr 2012
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QProcess setEnvirontment fails

    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.

    Qt Code:
    1. void MainWindow::appItemClicked(const QString &appName)
    2. {
    3. QJsonObject jo = getApplicationInfo(appName);
    4. auto joEnv = jo.value(QString("env")).toObject();
    5. auto joBin = jo.value(QString("bin")).toArray();
    6.  
    7. foreach (auto val, joBin)
    8. args << val.toString();
    9.  
    10. auto env = QProcess::systemEnvironment();
    11. foreach (auto key, joEnv.keys())
    12. {
    13. auto newValue = joEnv.value(key).toString();
    14. env.insert(key, newValue);
    15. }
    16. QProcess process;
    17. process.setProgram(args[0]);
    18. args.pop_front();
    19. if (args.count() > 0)
    20. process.setArguments(args);
    21. process.setProcessEnvironment(env);
    22. process.startDetached();
    23. process.waitForFinished(-1);
    24. }
    To copy to clipboard, switch view to plain text mode 

    getApplicationInfo () returns this data
    Qt Code:
    1. {
    2. "env": {
    3. "FOUNDRY_LOG_FILE": "/Scratch/log/nuke/nuke11.log",
    4. "RLM_LICENSE": "port@ip_address",
    5. },
    6. "bin": [
    7. "/usr/local/Nuke11/Nuke",
    8. "--nukex"
    9. ]
    10. }
    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
    Qt Code:
    1. #!/bin/bash
    2.  
    3. export FOUNDRY_LOG_FILE=~/software/Scratch/log/nuke/nuke11.log
    4. export RLM_LICENSE=port@ip_address
    5.  
    6. /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
    Last edited by nkpatro; 28th May 2021 at 04:05.

  2. #2
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    503
    Thanks
    11
    Thanked 76 Times in 74 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QProcess setEnvirontment fails

    Hi, did you check your "env" variable after the "foreach" loop to see if your additions are made, and if they are in the correct format?

    Ginsengelf

  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QProcess setEnvirontment fails

    Line 3 of your getApplicationInfo output, an absolute path, is not the same path as line 3 of the Bash script, a path relative to your home directory. You are not likely to be able to write in that location (if it exists at all).
    Are you sure the license is the problem?

Similar Threads

  1. Replies: 1
    Last Post: 3rd June 2013, 14:11
  2. Replies: 0
    Last Post: 23rd March 2013, 20:23
  3. Replies: 0
    Last Post: 26th August 2010, 11:44
  4. QProcess inside QProcess
    By bunjee in forum Qt Programming
    Replies: 7
    Last Post: 4th December 2008, 01:39
  5. QProcess::startDetached fails on Mac
    By sgmurphy19 in forum Qt Programming
    Replies: 1
    Last Post: 20th September 2008, 10:26

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.