QTextStream: discard+comment the possibility of file opening failure
The QTextStream(FILE*) constructor may fail to open the filehandle through QFile (e.g. if the open mode is incompatible). However QTextStream has no error report mechanism for this and still reports status Ok. This is consistent for instance with the QIODevice* constructor, where even passing a closed device sets the status to Ok. Add a comment and discard the return of open(). Change-Id: I430b96fd26e0ebca15a4d9ee640b09895bdd0b03 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>bb10
parent
e2413660f5
commit
9d118af92d
|
|
@ -1002,7 +1002,10 @@ QTextStream::QTextStream(FILE *fileHandle, OpenMode openMode)
|
|||
fileHandle, int(openMode));
|
||||
#endif
|
||||
QFile *file = new QFile;
|
||||
file->open(fileHandle, openMode);
|
||||
// Discarding the return value of open; even if it failed
|
||||
// (and the file is not open), QTextStream still reports `Ok`
|
||||
// for closed QIODevices, so there's nothing really to do here.
|
||||
(void)file->open(fileHandle, openMode);
|
||||
|
||||
Q_D(QTextStream);
|
||||
d->device = file;
|
||||
|
|
|
|||
Loading…
Reference in New Issue