i have subclasses kprocess and want to buffer output in a qstringlist.
when output is received i do this:
m1.lock();
for ( QStringList::Iterator it
= temp.
begin(); it
!= temp.
end();
++it
) mStdoutBuffer.append(*it);
m1.unlock();
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();
To copy to clipboard, switch view to plain text mode
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();
mStdoutBuffer.remove(*it);
m1.unlock();
return (Buffer);
} else
return ("");
/// 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 ("");
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
Bookmarks