QProcess crashes second QProcess
In my code I launch two mplayer clients to process two RTSP streams. However when I launch the program most of the time, only one of the process will work the other either disappears or never appears in the first place.
Below is my constructor for this process
Code:
{
p.
setColor(QPalette::Background, Qt
::black);
this->setAutoFillBackground(true);
this->setPalette(p);
this->setMinimumSize(720,576);
qDebug("\nCreating Process = Mplayer");
arguments << rtsp_path << " -vo gl:yuv=2:force-pbo:ati-hack -fps 25 ";
this->m_process->setProgram(program);
this->m_process->setArguments(arguments);
this->m_process->start();
if(this
->m_process
->state
()==QProcess::Running) {
qDebug("\nSuccess in starting Process = Mplayer");
}
if(!this->m_process->waitForStarted())
{
qDebug("\nFailed To start Process = Mplayer");
}
}
Below is the wrapper that holds these QProcesses.
Code:
mplayer_wrapper
::mplayer_wrapper(QWidget *parent
) :{
p.
setColor(QPalette::Background, Qt
::black);
this->setAutoFillBackground(true);
this->setPalette(p);
this->setMinimumSize(720,576);
this->setMaximumSize(1440,576);
this->setLayout(hlayout);
if ((rtsp_path_cam_1 != nullptr)&&(rtsp_path_cam_2 != nullptr))
{
this->setFixedSize(1440,576);
}
else if((rtsp_path_cam_1 != nullptr)&&(rtsp_path_cam_2 == nullptr))
{
this->setFixedSize(720,576);
}
else if((rtsp_path_cam_1 == nullptr)&&(rtsp_path_cam_2 != nullptr))
{
this->setFixedSize(720,576);
}
else
{
qDebug("Error no camera's");
}
}
mplayer_wrapper::~mplayer_wrapper()
{
qDebug("\nDeleting Process = mplayer_wrapper");
}
void mplayer_wrapper::start_mplayer()
{
if ((!player)&&(rtsp_path_cam_1 != nullptr)) // Only allow one instance of the pointer to be generated.
{
player = new mplayer(rtsp_path_cam_1);
hlayout->addWidget(player);
count += 1;
}
if ((!player2)&&(rtsp_path_cam_2 != nullptr)) // Only allow one instance of the pointer to be generated.
{
player2 = new mplayer(rtsp_path_cam_2);
hlayout->addWidget(player2);
count += 1;
}
}
If anyone has any idea why this is failing to launch the second mplayer client that would be great.As currently a bit lost really, as the code seems fine but I just cant see why it is failing.
Re: QProcess crashes second QProcess
There is no evidence of a "crash" in your post.
You are starting "program" (wherever that is defined) with the string " -vo gl:yuv=2:force-pbo:ati-hack -fps 25 " as a single argument. This is unlikely to be correct, and causing the process to simply fail. Try:
Code:
arguments << rtsp_path << "-vo" << "gl:yuv=2:force-pbo:ati-hack" << "-fps" << "25";
for a start. If the started signal is not emitted your constructor will block for something like 30 seconds.
Btw, your QProcess object is in danger of becoming a memory leak.