summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@nokia.com>2012-06-11 13:32:17 +0200
committerQt by Nokia <qt-info@nokia.com>2012-06-26 19:30:00 +0200
commit98803a76b3a423cad8e0287337d5cfc5f8aae58c (patch)
treebfc6a4757b244a8e530b4193dc73e1d80b123832 /src
parent003d294cd6cd0567a24cddb7e27ba5880fd2a599 (diff)
Fix QIODevice warning when running rcc.
When opening a QFile on stdout, for example, we must not call seek as it is a sequential device. This has been flagged as a warning since commit Ie3a96d3a and has resulted in spurious warnings being emitted. In the case of opening a QFile in Append mode, QIODevice::open already sets the position marker, so calling seek is redundant. This is also true for the file engine's open function (called through openExternalFile()), which also ensures the handle or descriptor is repositioned appropriately. Task-number: QTBUG-26104 Change-Id: I71040c399efe54e7538f54433368b432e959e08d Reviewed-by: Kent Hansen <kent.hansen@nokia.com> Reviewed-by: Joerg Bornemann <joerg.bornemann@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/io/qfile.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp
index 22b8ae5d2d..dc926caa1f 100644
--- a/src/corelib/io/qfile.cpp
+++ b/src/corelib/io/qfile.cpp
@@ -902,12 +902,12 @@ bool QFile::open(FILE *fh, OpenMode mode, FileHandleFlags handleFlags)
}
if (d->openExternalFile(mode, fh, handleFlags)) {
QIODevice::open(mode);
- if (mode & Append) {
- seek(size());
- } else {
+ if (!(mode & Append) && !isSequential()) {
qint64 pos = (qint64)QT_FTELL(fh);
- if (pos != -1)
- seek(pos);
+ if (pos != -1) {
+ // Skip redundant checks in QFileDevice::seek().
+ QIODevice::seek(pos);
+ }
}
return true;
}
@@ -960,12 +960,12 @@ bool QFile::open(int fd, OpenMode mode, FileHandleFlags handleFlags)
}
if (d->openExternalFile(mode, fd, handleFlags)) {
QIODevice::open(mode);
- if (mode & Append) {
- seek(size());
- } else {
+ if (!(mode & Append) && !isSequential()) {
qint64 pos = (qint64)QT_LSEEK(fd, QT_OFF_T(0), SEEK_CUR);
- if (pos != -1)
- seek(pos);
+ if (pos != -1) {
+ // Skip redundant checks in QFileDevice::seek().
+ QIODevice::seek(pos);
+ }
}
return true;
}