Results 1 to 2 of 2

Thread: QProcess crashes second QProcess

  1. #1
    Join Date
    Sep 2014
    Posts
    11
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default 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

    Qt Code:
    1. mplayer::mplayer(QString rtsp_path, QWidget *parent) :
    2. QWidget(parent)
    3. {
    4. QPalette p(palette());
    5. p.setColor(QPalette::Background, Qt::black);
    6. this->setAutoFillBackground(true);
    7. this->setPalette(p);
    8. this->setMinimumSize(720,576);
    9.  
    10.  
    11. qDebug("\nCreating Process = Mplayer");
    12. arguments << rtsp_path << " -vo gl:yuv=2:force-pbo:ati-hack -fps 25 ";
    13. this->m_process = new QProcess();
    14.  
    15. this->m_process->setProgram(program);
    16. this->m_process->setArguments(arguments);
    17. this->m_process->start();
    18.  
    19. if(this->m_process->state()==QProcess::Running)
    20. {
    21. qDebug("\nSuccess in starting Process = Mplayer");
    22.  
    23. }
    24. if(!this->m_process->waitForStarted())
    25. {
    26. qDebug("\nFailed To start Process = Mplayer");
    27. }
    28. }
    To copy to clipboard, switch view to plain text mode 

    Below is the wrapper that holds these QProcesses.
    Qt Code:
    1. mplayer_wrapper::mplayer_wrapper(QWidget *parent) :
    2. QWidget(parent)
    3. {
    4. QPalette p(palette());
    5. p.setColor(QPalette::Background, Qt::black);
    6. this->setAutoFillBackground(true);
    7. this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    8. this->setPalette(p);
    9. this->setMinimumSize(720,576);
    10. this->setMaximumSize(1440,576);
    11.  
    12. hlayout = new QHBoxLayout();
    13.  
    14. this->setLayout(hlayout);
    15.  
    16. if ((rtsp_path_cam_1 != nullptr)&&(rtsp_path_cam_2 != nullptr))
    17. {
    18. this->setFixedSize(1440,576);
    19. }
    20. else if((rtsp_path_cam_1 != nullptr)&&(rtsp_path_cam_2 == nullptr))
    21. {
    22. this->setFixedSize(720,576);
    23. }
    24. else if((rtsp_path_cam_1 == nullptr)&&(rtsp_path_cam_2 != nullptr))
    25. {
    26. this->setFixedSize(720,576);
    27. }
    28. else
    29. {
    30. qDebug("Error no camera's");
    31. }
    32. }
    33.  
    34. mplayer_wrapper::~mplayer_wrapper()
    35. {
    36. qDebug("\nDeleting Process = mplayer_wrapper");
    37. }
    38.  
    39. void mplayer_wrapper::start_mplayer()
    40. {
    41.  
    42. if ((!player)&&(rtsp_path_cam_1 != nullptr)) // Only allow one instance of the pointer to be generated.
    43. {
    44. player = new mplayer(rtsp_path_cam_1);
    45. hlayout->addWidget(player);
    46. count += 1;
    47. }
    48. if ((!player2)&&(rtsp_path_cam_2 != nullptr)) // Only allow one instance of the pointer to be generated.
    49. {
    50. player2 = new mplayer(rtsp_path_cam_2);
    51. hlayout->addWidget(player2);
    52. count += 1;
    53. }
    54.  
    55. }
    To copy to clipboard, switch view to plain text mode 


    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.

  2. #2
    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 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:
    Qt Code:
    1. arguments << rtsp_path << "-vo" << "gl:yuv=2:force-pbo:ati-hack" << "-fps" << "25";
    To copy to clipboard, switch view to plain text mode 
    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.

Similar Threads

  1. Replies: 1
    Last Post: 3rd June 2013, 13:11
  2. Replies: 0
    Last Post: 23rd March 2013, 19:23
  3. Replies: 11
    Last Post: 18th September 2012, 10:15
  4. Replies: 0
    Last Post: 26th August 2010, 10:44
  5. Replies: 4
    Last Post: 13th February 2006, 11:35

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.