PDA

View Full Version : deleting first item in a list



soul_rebel
6th April 2006, 17:38
i have subclasses kprocess and want to buffer output in a qstringlist.
when output is received i do this:

m1.lock();
QStringList temp = QStringList::split('\n', QString::fromLatin1(buffer, buflen));
for ( QStringList::Iterator it = temp.begin(); it != temp.end(); ++it )
mStdoutBuffer.append(*it);
m1.unlock(); and when the buffer is read this code is exeuted:
/// reads first line from Buffer and then removes it so content "moves up"
if (canReadLineStdout() && ( m1.tryLock()))
{
QString Buffer = mStdoutBuffer.first();
QStringList::Iterator it = mStdoutBuffer.begin();
mStdoutBuffer.remove(*it);
m1.unlock();
return (Buffer);
} else
return (""); 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

jpn
6th April 2006, 17:44
So, as I stated in another thread, QMutext::tryLock() already locks the mutex unless another thread has locked it.. :)

soul_rebel
6th April 2006, 17:49
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