I tried to put some debug statements to see where it exactly crash. The segmentaion fault does not provide me any information. As soon as I call CreateContorls( ) to call two sequential process my application crash. It never prints any thing else . It looks like Slots readFirstProcess and readSecondProcess never get called otherwise it should print debug statements from slots such as "Print ReadOut Process1".
The output I receive after calling CreateControls() method is :-
Print Statement 1
Print Statement 2
Print Statement 3
Print Statement 4
Print Statement 5
Print Statement 6
But if executes only one process with GetFirstProcess( ) while commenting out second GetSecondProcess() then there is no problem.
QString CMainTemplate
::CreateControls() {
lineEdit->setText(GetFirstProcess());
//lineEdit2->setText(GetSecondProcess());
}
QString CMainTemplate::CreateControls()
{
lineEdit->setText(GetFirstProcess());
//lineEdit2->setText(GetSecondProcess());
}
To copy to clipboard, switch view to plain text mode
QString CMainTemplate
::CreateControls() {
lineEdit->setText(GetFirstProcess());
lineEdit2->setText(GetSecondProcess());
}
QString CMainTemplate
::GetFirstProcess() {
//Add the arguments
process1->addArgument( "/bash" );
process->addArgument("GetFirstScript");
qDebug("Print Statement 1");
connect(process, SIGNAL(readyReadStdout()), this, SLOT(readFirstProcess()));
qDebug("Print Statement 2");
if ( !process->start() )
{
qDebug("ERROR: First Process Never Started");
process->deleteLater();
}
qDebug("Print Statement 3");
return strFirstProcess;
}
//...SECOND PROCESS
QString CMainTemplate
::GetSecondProcess() {
//Add the arguments
process1->addArgument( "/bash" );
process1->addArgument("GetSecondScript");
qDebug("Print Statement 4");
connect(process1, SIGNAL(readyReadStdout()), this, SLOT(readSecondProcess()));
qDebug("Print Statement 5");
if ( !process1->start() )
{
qDebug("ERROR: Second Process Never Started");
process->deleteLater();
}
qDebug("Print Statement 6");
return strSecondProcess;
}
//=====================SLOTS TO READ STD OUT ===================================================
void CMainTemplate::readFirstProcess()
{
QString str
= process
->readStdout
() ;
strFirstProcess = str;
qDebug("Print ReadOut Process1);
process->deleteLater();
}
void CMainTemplate::readSecondProcess()
{
QString str = process1->readStdout() ;
strSecondProcess = str;
qDebug("Print ReadOut Process2);
process1->deleteLater();
}
QString CMainTemplate::CreateControls()
{
lineEdit->setText(GetFirstProcess());
lineEdit2->setText(GetSecondProcess());
}
QString CMainTemplate::GetFirstProcess()
{
process= new QProcess(this);
//Add the arguments
process1->addArgument( "/bash" );
process->addArgument("GetFirstScript");
qDebug("Print Statement 1");
connect(process, SIGNAL(readyReadStdout()), this, SLOT(readFirstProcess()));
qDebug("Print Statement 2");
if ( !process->start() )
{
qDebug("ERROR: First Process Never Started");
process->deleteLater();
}
qDebug("Print Statement 3");
return strFirstProcess;
}
//...SECOND PROCESS
QString CMainTemplate::GetSecondProcess()
{
process1= new QProcess(this);
//Add the arguments
process1->addArgument( "/bash" );
process1->addArgument("GetSecondScript");
qDebug("Print Statement 4");
connect(process1, SIGNAL(readyReadStdout()), this, SLOT(readSecondProcess()));
qDebug("Print Statement 5");
if ( !process1->start() )
{
qDebug("ERROR: Second Process Never Started");
process->deleteLater();
}
qDebug("Print Statement 6");
return strSecondProcess;
}
//=====================SLOTS TO READ STD OUT ===================================================
void CMainTemplate::readFirstProcess()
{
QString str = process->readStdout() ;
strFirstProcess = str;
qDebug("Print ReadOut Process1);
process->deleteLater();
}
void CMainTemplate::readSecondProcess()
{
QString str = process1->readStdout() ;
strSecondProcess = str;
qDebug("Print ReadOut Process2);
process1->deleteLater();
}
To copy to clipboard, switch view to plain text mode
Bookmarks