Results 1 to 5 of 5

Thread: Qprocess buffer to small?

  1. #1
    Join Date
    Jul 2008
    Posts
    7
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Qprocess buffer to small?

    Hello,
    I am trying to get a list of information from a program to my qt-program.
    When receiving small amounts of data, there is no problem.
    However when im receiving 500,000 bytes of tekst-information it crashes. I cannot find a single way to prevent this.
    I am trying to buffer by using the following function:
    Qt Code:
    1. void MainWindow::ViewDirReadStandardOutput()
    2. {
    3. qDebug() << ls->readLine() << ls->size();
    4. if(ls->size() > 0){
    5. ViewDirReadStandardOutput();
    6. }
    7. }
    To copy to clipboard, switch view to plain text mode 
    I am using qDebug to see how far the program gets, this would be replaced by a QStringlist when working.
    Could anybody help me with this?

    -Xtreme
    Last edited by wysota; 15th July 2008 at 15:13. Reason: missing [code] tags

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Qprocess buffer to small?

    This is not really how this method should look like... It should be a slot connected to a readyRead() signal and it should contain:

    Qt Code:
    1. while(ls->canReadLine()){
    2. qDebug() << ls->readLine();
    3. }
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Jul 2008
    Posts
    7
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Qprocess buffer to small?

    I have deleted the old code contents of the posted function and added
    To the function where the ls process is created:
    Qt Code:
    1. connect( ls, SIGNAL(readyRead()),
    2. this, SLOT(storedata()) );
    To copy to clipboard, switch view to plain text mode 
    and
    Qt Code:
    1. void MainWindow::storedata(){
    2. while(ls->canReadLine()){
    3. qDebug() << ls->readLine();
    4. }
    5. }
    To copy to clipboard, switch view to plain text mode 
    However it still crashes after about 400 lines.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Qprocess buffer to small?

    Certainly not because of buffer overflow. If the buffer filled, the process would have stopped and waited until you would emptied it. I suggest you take a debugger and see where it crashes.

  5. #5
    Join Date
    Jul 2008
    Posts
    7
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Qprocess buffer to small?

    Thanks for the reply. After debugging it (took a while to find out which debugger was the best) it appeared there was a read error function which made it crash.

Similar Threads

  1. Detect First QProcess finished in a group and kill other
    By Davidaino in forum Qt Programming
    Replies: 3
    Last Post: 11th July 2008, 12:53
  2. QProcess and Pipes
    By KaptainKarl in forum Qt Programming
    Replies: 1
    Last Post: 9th April 2007, 23:11
  3. QProcess extremely slow on Windows?
    By Pepe in forum Qt Programming
    Replies: 2
    Last Post: 26th March 2007, 00:25
  4. QProcess / system call not working under linux. Why?
    By johnny_sparx in forum Qt Programming
    Replies: 12
    Last Post: 11th March 2006, 00:32

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.