mirror of https://github.com/vitalif/phantomjs
Flush in `File::write` when in unbuffered "text" mode
If the wrapped `QFile` was opened with `QIODevice::Unbuffered`, any writes should be unbuffered. However, as currently implemented, using `QTextStream` when the `File` is in "text" mode causes all reads/writes to be buffered. This modification forces a flush in `File::write` if the wrapped `QFile` was opened with `QIODevice::Unbuffered`. Necessary to fix issue #11162 https://github.com/ariya/phantomjs/issues/11162.1.x
parent
24078b56c7
commit
8042f3b92c
|
@ -123,6 +123,9 @@ bool File::write(const QString &data)
|
|||
if ( m_fileStream ) {
|
||||
// text file
|
||||
(*m_fileStream) << data;
|
||||
if (_isUnbuffered()) {
|
||||
m_fileStream->flush();
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
// binary file
|
||||
|
@ -213,6 +216,13 @@ void File::close()
|
|||
deleteLater();
|
||||
}
|
||||
|
||||
// private:
|
||||
|
||||
bool File::_isUnbuffered() const
|
||||
{
|
||||
return m_file->openMode() & QIODevice::Unbuffered;
|
||||
}
|
||||
|
||||
|
||||
// FileSystem
|
||||
// public:
|
||||
|
|
|
@ -65,6 +65,8 @@ public slots:
|
|||
void close();
|
||||
|
||||
private:
|
||||
bool _isUnbuffered() const;
|
||||
|
||||
QFile *m_file;
|
||||
QTextStream *m_fileStream;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue