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

alexander golks alex at golks.de
Wed May 9 11:39:35 CEST 2018


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
 */



More information about the Interest mailing list