[Interest] QFile::write(const QByteArray&) does not write all data?

alexander golks alex at golks.de
Wed May 9 12:08:17 CEST 2018


yes. i am sure. was another hard time to learn this ;)

Am Wed, 9 May 2018 11:57:08 +0200
schrieb Helmut Mülner <helmut.muelner at gmail.com>:

> Are you sure your QByteArray has the correct size?
> If your constructed it from a const char* and did not give the size, it may
> contain only data up to the first zero byte.
> 
> helmut
> 
> -----Ursprüngliche Nachricht-----
> Von: Interest
> [mailto:interest-bounces+helmut.muelner=gmail.com at qt-project.org] Im Auftrag
> von alexander golks
> Gesendet: Mittwoch, 9. Mai 2018 11:40
> An: interest at qt-project.org
> Betreff: Re: [Interest] QFile::write(const QByteArray&) does not write all
> data?
> 
> Am Wed, 09 May 2018 09:24:58 +0000
> schrieb Vadim Peretokin <vperetokin at gmail.com>:
> 
> yes, i tried flushing the file, too. but this changed nothing.
> 
> i now have same do while loop as in
>   qint64 QFSFileEnginePrivate::nativeWrite(const char *data, qint64 len) and
> this works. this writes complete file.
> 
> but i think, QFile implementation is wrong here.
> i think nativeWrite should set error and return -1 on every chunk, not only
> at first chunk.
> 
> alex
> 
> > Obvious question but do you flush?
> > 
> > On Wed, May 9, 2018 at 11:09 AM alexander golks <alex at golks.de> wrote:
> >   
> > > hi,
> > >
> > > i recently stumbled over this situation, running on windows 7 using 
> > > qt-5.6.3.
> > > when trying to write ~50MB of data, write does not always complete, 
> > > the file does not contain all data, yet no error is returned.
> > >
> > > i always thought, QFile::write(const QByteArray&) is meant to write 
> > > all data.
> > > as stated in the documentation for: qint64 
> > > QIODevice::writeData(const char *data, qint64 maxSize) "When 
> > > reimplementing this function it is important that this function 
> > > writes all the data available before returning."
> > >
> > > is this a bug in QFile?
> > > or do i have to do-while loop to write the rest of my data?
> > > but wouldn't this lead missing writes in QDataStream + QFile, as 
> > > QDataStream needs complete writes, too?
> > >
> > > alex
> > >
> > > --
> > > /*
> > >  *  Learn to pause -- or nothing worthwhile can catch up to you.
> > >  */
> > > _______________________________________________
> > > Interest mailing list
> > > Interest at qt-project.org
> > > http://lists.qt-project.org/mailman/listinfo/interest
> > >    
> 
> 
> --
> /*
>  *  printk("ip6t_hook: happy cracking.\n");
>  *          linux-2.6.6/net/ipv6/netfilter/ip6table_filter.c
>  */
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
> 


-- 
/*
 *  You are number 6!  Who is number one?
 */



More information about the Interest mailing list