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

alexander golks alex at golks.de
Fri May 11 13:08:48 CEST 2018


Am Fri, 11 May 2018 18:05:11 +0800
schrieb Elvis Stansvik <elvstone at gmail.com>:

> Not sure why you bring up this piece of MS docs, when this is about QFile.

this is about qfile on windows 7. the implementation is using WriteFile. sources for documentation are in msdn, too.
this is, what its about.

> It is not silent, you have the return value so you can detect when the
> number of written bytes is not equal to the size of the data.

the error is 0. and errorString() is "no error", too.
so how to evaluate for error or no error?
when to break my own do-while loop, when i cannot detect errors?
 
> QDataStream will check if the number of bytes written is equal to the
> expected. If it is not, it will put itself into
> QDataStream::WriteFailed state, which can be checked for by the user.
> 
> I'm really not sure what you're suprised by here :P

the surprise is: there is no error. i can run my own do-offsetwriting-loop around the internal QFile do-offsetwriting-loop. this works great.
but i cannot use QDataStream anymore, because it fails on some strange yet to be found error. sometimes.

i still think, that QFile (whatever internal part) is buggy here.
QFile should evaluate this sitation better and either continue writing or return with correct error.

i'll have to review a lot of code now ;) and add do-offsetwriting-while loop to it.

-- 
/*
 *  When angry, count four; when very angry, swear.
 *      -- Mark Twain, "Pudd'nhead Wilson's Calendar"
 */



More information about the Interest mailing list