Skip to content

Illogical result of the write function. #211

@pefedotov

Description

@pefedotov

The write function is defined in the QIODevice class. It should, according to the documentation, return the number of bytes written. But, instead of the number of bytes, it returns the number of bytes not written!
The contents of the write function are shown below

QCoro::Task<qint64> QCoroIODevice::write(const QByteArray &buffer) {
     auto bytesWritten = mDevice->write(buffer);
     while (bytesWritten > 0) {
         const auto flushed = co_await waitForBytesWritten(-1);
         bytesWritten -= flushed.value();
     }

     co_return bytesWritten;
}

As you can see, the number of bytes is constantly decreasing and if successful, the result of the function will be 0.
This is definitely not the number of bytes written.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions