[Interest] QFile::write(const QByteArray&) does not write all data?
alexander golks
alex at golks.de
Fri May 11 08:11:04 CEST 2018
hi,
> have you seen https://bugreports.qt.io/browse/QTBUG-56616 ?
> Your problem sounds a bit like it, although the bug should be fixed in
> Qt 5.6.3.
i have had a look now, and my file is only ~50MB in this case, so this bug should be no problem.
besides, i am running on 5.6.3, as i haven't a previous version installed currently.
> > i always thought, QFile::write(const QByteArray&) is meant to write all
> > data.
>
> Yes, but it also returns a qint64 that is the number of bytes written. What
> did it return in your case?
my code was:
qint64 res = f.write(data);
with data.size() == 51489714
and res == 33554432
the only possible issue i see is with the 2nd if here in qint64 QFSFileEnginePrivate::nativeWrite(const char *data, qint64 len)
if (!WriteFile(fileHandle, data + totalWritten, currentBlockSize, &bytesWritten, NULL)) {
if (totalWritten == 0) {
// Note: Only return error if the first WriteFile failed.
q->setError(QFile::WriteError, qt_error_string());
return -1;
}
break;
}
i think it "silently" breaks here without setting error condition on the QFile when hitting errors
on all chunks but the first one, thus returning a size lower the input array size, which is the behaviour i see.
alex
--
/*
* printk(KERN_DEBUG "%s: BUG... transmitter died. Kicking it.\n",...)
* linux-2.6.6/drivers/net/acenic.c
*/
More information about the Interest
mailing list