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

alexander golks alex at golks.de
Tue May 15 08:31:30 CEST 2018


Am Mon, 14 May 2018 08:45:06 -0700
schrieb Thiago Macieira <thiago.macieira at intel.com>:

> ...
> 
> It's a matter of perspective. As seen in this thread, in some situations 
> failing to write everything is an unrecoverable situation. That is the case 
> here: QDataStream cannot recover from a partial write.
> 
> We could loop retrying the write so long as ret > 0. This is probably 
> acceptable here, since the alternative is to go into WriteFailed state anyway.
> 
> Would you submit an update?
> 
> ...
> 
> The other methods do the same:
> 
> QDataStream &QDataStream::operator<<(qint16 i)
> {
>     CHECK_STREAM_WRITE_PRECOND(*this)
>     if (!noswap) {
>         i = qbswap(i);
>     }
>     if (dev->write((char *)&i, sizeof(qint16)) != sizeof(qint16))
>         q_status = WriteFailed;
>     return *this;
> }
> 
> Inserting the loop requires a bit of refactoring to centralise the writing to 
> the device.
> 
> ...
> 
> Please submit via the code review system.
> 

ok, i'll give it a try when i succeed in setting this all up here ;)

thanks for all input!

-- 
/*
 *  printk("you lose buddy boy...\n");
 *          linux-2.6.6/arch/sparc/kernel/traps.c
 */



More information about the Interest mailing list