-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Wednesday 31 July 2002 05:18, David Bishop wrote: > On Monday 29 July 2002 05:38 pm, Rob Kaper wrote: > > On Tuesday 30 July 2002 01:09, David Bishop wrote: > > Wouldn't this also work: > > > > QStringList errors = QStringList::split( "\n", QString::fromLocal8Bit( > > buffer, buflen )); > > > > and in the loop error_listbox->insertItem(*it); > > > > (of course one should check for a valid *it as well, by adding && (*it) > > to the loop condition) > > > > Rob > > Well, it *should* work :-) However, when I force an error in xmame, > I get a crash in kmame, with the following to stdout (and bt attached): > > ASSERT: "it.node != node" in /usr/include/qt/qvaluelist.h (274) > > My code now looks like this: > > void MainDialog::ReadStderr(KProcess *, char *buffer, int buflen) > { > > QString s = QString::fromLocal8Bit( buffer, buflen ); > QStringList errors = QStringList::split( "\n", s ); > > if ( !m_str.isEmpty() ) { > errors.first().prepend(m_str); > m_str = QString::null; > } > > if ( s.at(buflen) != '\n' ) { > m_str = errors.last(); > errors.pop_back(); > } > > for ( QStringList::Iterator it = errors.begin() ; (it != errors.end() > && (*it)); ++it ) { error_listbox->insertItem(*it); > } > > error_listbox->setBottomItem(error_listbox->count()); > } > > I've also tried replacing the s.at(buflen) with s.at(s.length()) but that > didn't seem to affect anything . at(..) uses the index, which is zeroth counted... so you want: s.at(buflen - 1); also, not that it probably really matters, but the check for (*it) shouldn't be necessary in your for loop because you know it's origins (the QStringList::split above). you are pretty well guarenteed it will be alright. - -- Aaron J. Seigo GPG Fingerprint: 8B8B 2209 0C6F 7C47 B1EA EE75 D6B7 2EB1 A7F1 DB43 "Everything should be made as simple as possible, but not simpler" - Albert Einstein -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.7 (GNU/Linux) iD8DBQE9SHhq1rcusafx20MRAv+qAKCEH0bU/gTS1qrMqyoQ3Sil775cpQCgrRSk PRcEtLj/HGoEj2+O1pYQSAc= =T4bt -----END PGP SIGNATURE----- >> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<