Project Home
Project Home
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - using pictures with spawnl(): (5 Items)
   
using pictures with spawnl()  
Hi there :)

I have the following problem:

I am using spawnl() to start new qt-programs/processes on Beagleboard-xM with QNX 6.5 SP1 ( qnx_bglxm - example from 
dennis). This is also already working but if I try to start a qt-program with pictures then i get the following error:

>>"QImage::scaled: Image is a null image"<<

If I start this program directly via QNX Momentics (qconn) or via shell then I don´t have this error. I also tried to 
open these pictures with fopen() and that is working.

>>    printf("%s\n", "opening with fopen()");                         <<
>>    datei = fopen("/Vererbung/Bilder/Zeiger.png", "r");      <<
>>    if(datei == NULL)                                                            <<
>>    {printf("%s\n", "opening with fopen() not working");}  <<
>>    else                                                                                 <<
>>    {printf("%s\n", "opening with fopen() ok!");}                <<

Now I was told in another forum that it could be a problem with the qt-routine and not a permission problem because 
fopen() works.
For loading the picture into the QImage I use:

>> arrow->load(QString(QCoreApplication::applicationDirPath() + "/pictures/arrow.png"));  <<

Does someone have an idea what my problem could be?

ps.: I am not using the shell, because it messes my connection to the serial interface up and because of that I kill "sh
" at the beginning with "sigkill". (Sorry Dennis, but I still couldn´t figure out how to rebuild with the build script,
 but I still try! For now this way also works, but not so good I think ;)  )
Re: using pictures with spawnl()  
>>>I am not using the shell

This is the key - the difference is your environment variables.  Most likely, Qt cannot find its plugin to handle the 
image.

There are many versions of spawn*() function.  See the library reference.  Some allow you to create and pass an 
environment.  All the Qt variables need to be set or, as you have seen, Qt will have problems.

Using "system()" is often an easier way to go - but you still need to setup the environment.  You can do that in a 
script which you start via system().

#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>

int main(int argc, char *argv[])
{
	system( "/tmp/myscript");
	return EXIT_SUCCESS;
}

where /tmp/myscript - (chmod 777 !) is

export FOOBAR=/tmp/dennis
cat $FOOBAR
Re: using pictures with spawnl()  
Doesn´t system() need a running shell?
If I use system() with an command inside then: "If command isn't NULL, system() invokes a copy of the shell, and passes 
the string command to it for processing"
Does this mean that, if no shell is running, a new shell is started? Do I have to terminate this shell too? Because with
 a running shell I cannot communicate with the rs232-interface
( http://community.qnx.com/sf/discussion/do/listPosts/projects.qt/discussion.general.topc23701 )

With environment variable you mean these:

QWS_KEYBOARD = qnx
QWS_MOUSE_PROTO = qnx
QWS_DISPLAY = qnx

or not? These are the environment variables I set in QNX Momentics.

And at least:  FOOBAR is just an Placeholder for variable like QWS_... or not?
Re: using pictures with spawnl()  
>>>Doesn´t system() need a running shell?
System() runs a new shell.  If you add '&' and the command does not read/write stdin/stdout then it should not interfere with your serial port operation.  Besides, you can redirect stdio/stdout to /dev/null if there is an issue.

>>>With environment variable you mean these:
QWS_KEYBOARD = qnx
QWS_MOUSE_PROTO = qnx
QWS_DISPLAY = qnx

Yes (you can't have spaces though).  Isn't there also a variable for plugins?

>>>FOOBAR is just an Placeholder 
Yes

D


Re: using pictures with spawnl()  
It is working now! Thx Dennis!

I use now spawnle() with an environment char-array:
-------------------------------------------------------------------------
>>	char *env_list[] = {"QWS_DISPLAY=qnx",
>>						"QWS_KEYBOARD=qnx",
>>						"QWS_MOUSE_PROTO=qnx",
>>						NULL
>>						};
-------------------------------------------------------------------------
>>   chdir("/View");
>>   exit_val_View = spawnle( 3, "/View/View", "View", "-qws", NULL, env_list);
-------------------------------------------------------------------------