[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: porting from kde 1.x to 3.x
From:       David Bishop <tech () bishop ! dhs ! org>
Date:       2002-07-30 22:39:59
[Download RAW message or body]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


I'm back :-)

On Monday 29 July 2002 05:37 pm, David Faure wrote:
> On Tuesday 30 July 2002 01:09, David Bishop wrote:
> > As far as I can tell, he doesn't actually use this anywhere else, thus
> > making the "static" unnecessary, no?
>
> The idea is that this called every time the KProcess gets data.
> Any quantity of data. Might not terminate at the end of a '\n'
> So you need to at least keep the last unterminated line, between calls.
> Hence the need for a member var.

That makes sense.  Done.

> > void MainDialog::ReadStdout(KProcess *, char *buffer, int buflen)
> > {
> >     QString s = QString::fromLocal8Bit( buffer, buflen );
> >     QStringList errors = QStringList::split( "\n", s );
> >
> >     for ( QStringList::Iterator it = errors.begin(); it != errors.end();
> > ++it ) { error_listbox->insertItem(s);
> >     }
>
> This assumes you get full lines at each call, that won't be the case.

This also make sense.  And, after some thought, I figured out how to store
 the remainder, only keep the complete stuff, etc.  Now, if only it worked :-)

void MainDialog::ReadStderr(KProcess *, char *buffer, int buflen)
{

    QString s = QString::fromLocal8Bit( buffer, buflen );
    QStringList errors = QStringList::split( "\n", s );

    if ( m_str.isEmpty() == false ) {
      errors.first.prepend(m_str);
      m_str = "";
    }

    if ( s.at(buflen) != '\n' ) {
      m_str = errors.last();
      errors.pop_back();
    }

    for ( QStringList::Iterator it = errors.begin(); it != errors.end(); ++it ) {
         error_listbox->insertItem(*it);
    }

    error_listbox->setBottomItem(error_listbox->count());
}

You can probably see the problem right off the bat.  Well, the compiler 
did ;-)  I can't just do "errors.first.prepend" (overloaded not supported by 
dump_expr?).  Do I need to peel the first off into another string, prepend 
m_str, and push it back on the front?  That seems akward...  Or am I 
confusing my languages again, and should be using ->, or ::, or %^#<, :-P

- -- 
A mouse is a device used to point at the xterm you want to type in. 
  --Kim Alm, a.s.r 
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE9RxXBEHLN/FXAbC0RAsFGAJ9k2EQ8C+daBD/+uB3OceL6AjvoHQCeLyjm
nqlWFSu/NHHPTNF9d43srac=
=9Sx7
-----END PGP SIGNATURE-----

 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic