PDA

View Full Version : exited with code -1073741819



cic
10th November 2011, 10:13
im currently working with qt and have linked an external program to my qt project.
I want to display the output of my external program on compile output area as well.

so the code is as follow. After QT finished compiling, I run the project, and from compile area i can see it goes to "zou can see from the debug area....."
while the qt program just crashed, with warning : .....exited with code -1073741819
void myProject::Project(){
QObject *parent= 0;
QProcess *myProcess = new QProcess (parent);
connect(myProcess, SIGNAL(finished(int)), SLOT(playPause()));
qDebug() << connect(myProcess, SIGNAL(readyReadStandardError()), this, SLOT(updateError()));
qDebug() << connect(myProcess, SIGNAL(readyReadStandardOutput()), this, SLOT(updateText()));
myProcess->start("./sampledata/externalprogram.exe")
qDebug()<< "you can see from the debug area how he is running.";

}

void myProject::updateError(){
QByteArray data = myProcess->readAllStandardError();
qDebug()<< data;
}

void myProject::updateText(){
QByteArray data = myProcess->readAllStandardOutput();
qDebug()<< data;
}


anybody help ?

Santosh Reddy
11th November 2011, 04:32
comment this line and run again

//myProcess->start("./sampledata/externalprogram.exe")
if the program still exits, then the problem is in external program.

also is better to do this

...
QProcess *myProcess = new QProcess(this);
...

ChrisW67
11th November 2011, 07:02
If I had a dollar for every time...

This particular error has been addressed quite a few times in these forums.
-1073741819 = 0xC0000005 = Access violation.

You are looking for things like using uninitialized or NULL pointers in your code, calling delete on something that wasn't allocated on the heap, calling delete twice etc.

Nothing obvious sticks out in the bit of code you have posted (except that your QProcess is a memory leak).

cic
11th November 2011, 10:53
thanks for both of you.

i did search here and there were similar problem before.

just dont get them at the first time.

hope it works in this time :)

d_stranz
12th November 2011, 00:39
void myProject::Project(){
QObject *parent= 0;
QProcess *myProcess = new QProcess (parent);
connect(myProcess, SIGNAL(finished(int)), SLOT(playPause()));
qDebug() << connect(myProcess, SIGNAL(readyReadStandardError()), this, SLOT(updateError()));
qDebug() << connect(myProcess, SIGNAL(readyReadStandardOutput()), this, SLOT(updateText()));
myProcess->start("./sampledata/externalprogram.exe")
qDebug()<< "you can see from the debug area how he is running.";

}

void myProject::updateError(){
QByteArray data = myProcess->readAllStandardError();
qDebug()<< data;
}

void myProject::updateText(){
QByteArray data = myProcess->readAllStandardOutput();
qDebug()<< data;
}


The problem is that in line 3, you define "myProcess" as a local variable within your Project() method. You then try to use it in lines 13 and 18 to read data. As written, this code should not even compile, because "myProcess" is not defined in the two slot methods. Since it does compile and run apparently you have also defined it as a member variable of your myProject class, but in the Project() method, the local variable has scope precedence over the class member variable, so as far as the two slots are concerned, "myProcess" is an uninitialized pointer and thus causes the access violation.

Please use CODE tags when posting source code.