KDE/kdelibs/kdeprint
Simon Hausmann
hausmann at kde.org
Thu Jun 28 09:12:44 BST 2007
On Friday 15 June 2007 18:57:54 Andreas Pakulat wrote:
> On 15.06.07 18:45:03, Oswald Buddenhagen wrote:
> > On Fri, Jun 15, 2007 at 04:02:14PM +0000, Andreas Pakulat wrote:
> > > --- trunk/KDE/kdelibs/kdeprint/tools/escputil/escpwidget.cpp
> > > #675966:675967 @@ -247,14 +247,16 @@
> > >
> > > void EscpWidget::slotReceivedStdout()
> > > {
> > > - QByteArray bufstr = m_proc.readAllStandardOutput();
> > > - m_outbuffer.append( QString::fromLocal8Bit( bufstr ) );
> > > + while( m_proc.canReadLine() )
> > > + m_outbuffer.append( QString::fromLocal8Bit( m_proc.readLine() ) );
> > > }
> >
> > ok, that's fine in theory (except that you don't handle a possible
> > final unterminated line, but that's an unlikely event, i suppose).
> >
> > in practice, there is a problem if a line arrives in multiple segments
> > and meanwhile data arrives on the other channel ... qprocess discards
> > the remaining read buffer on switching channels (including
> > readAllStandard*()). that means that always draining the entire buffer
> > and doing line splitting yourself is the only safe option when you have
> > configured SeparateChannels. oh, btw, tt is denying that this is a bug -
> > but hey, they accepted it as an enhancement.
>
> WTF! Thats not only not obvious but clearly a problem. How should a user
> of QProcess be able to read error and output separately without loosing
> data or having to store 2 buffers. Thats just insane, where's the "Code
> less, Create more" here?
>
> Any of our TT contacts want to speak up? Seriously the QProcess API is
> really hard to use, the documentation is lacking, thats not what I'm
> used to from Qt. And we're already at Qt4.3 here, its not like this
> class is new or anything.
I don't think is an API problem, it is plain data loss bug. We've fixed it for
Qt 4.3.1 and I've applied the patch to qt-copy. Switching read channels no
more looses data. Just use it as you'd expect it to work, the
readAllStandard(Output|Error) as well as the canReadLine/readLine while loop
should work just fine now.
Simon
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20070628/459f432b/attachment.sig>
More information about the kde-core-devel
mailing list