Results 1 to 3 of 3

Thread: deleting first item in a list

  1. #1
    Join Date
    Jan 2006
    Location
    germany
    Posts
    75
    Thanks
    9
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default deleting first item in a list

    i have subclasses kprocess and want to buffer output in a qstringlist.
    when output is received i do this:
    Qt Code:
    1. m1.lock();
    2. QStringList temp = QStringList::split('\n', QString::fromLatin1(buffer, buflen));
    3. for ( QStringList::Iterator it = temp.begin(); it != temp.end(); ++it )
    4. mStdoutBuffer.append(*it);
    5. m1.unlock();
    To copy to clipboard, switch view to plain text mode 
    and when the buffer is read this code is exeuted:
    Qt Code:
    1. /// reads first line from Buffer and then removes it so content "moves up"
    2. if (canReadLineStdout() && ( m1.tryLock()))
    3. {
    4. QString Buffer = mStdoutBuffer.first();
    5. QStringList::Iterator it = mStdoutBuffer.begin();
    6. mStdoutBuffer.remove(*it);
    7. m1.unlock();
    8. return (Buffer);
    9. } else
    10. return ("");
    To copy to clipboard, switch view to plain text mode 
    but i get
    QGVector::remove: Index 1343941632 out of range
    QGVector::insert: Index 1343941632 out of range


    what am i doing wrong? (the program mostly doesnt crash but something isnt well for sure)
    thanks
    Last edited by soul_rebel; 6th April 2006 at 17:51.
    Quote Originally Posted by Bertolt Brecht
    What is the robbing of a bank compared to the founding of a bank?

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: deleting first item in a list

    So, as I stated in another thread, QMutext::tryLock() already locks the mutex unless another thread has locked it..
    J-P Nurmi

  3. #3
    Join Date
    Jan 2006
    Location
    germany
    Posts
    75
    Thanks
    9
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: deleting first item in a list

    i know that, i just forgot to remove the line ...
    anway the QGVector errors remain (and they are the ones connected to the question really
    thanks
    Quote Originally Posted by Bertolt Brecht
    What is the robbing of a bank compared to the founding of a bank?

Similar Threads

  1. Replies: 8
    Last Post: 1st October 2015, 07:23
  2. ListWidget positions item
    By talex in forum Qt Programming
    Replies: 3
    Last Post: 21st October 2008, 15:16
  3. View, Scene, Item and thread??
    By dungsivn in forum Qt Programming
    Replies: 5
    Last Post: 20th August 2008, 19:21
  4. Item Delegate Painting
    By stevey in forum Qt Programming
    Replies: 3
    Last Post: 9th May 2008, 07:37
  5. list of custom item views?
    By Beluvius in forum Qt Programming
    Replies: 1
    Last Post: 29th March 2008, 06:43

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.