diff options
Diffstat (limited to 'src/gui/image/qimagereader.cpp')
-rw-r--r-- | src/gui/image/qimagereader.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/gui/image/qimagereader.cpp b/src/gui/image/qimagereader.cpp index d01f0d640b..cd7c95b166 100644 --- a/src/gui/image/qimagereader.cpp +++ b/src/gui/image/qimagereader.cpp @@ -565,6 +565,16 @@ bool QImageReaderPrivate::initHandler() // probe the file extension if (deleteDevice && !device->isOpen() && !device->open(QIODevice::ReadOnly) && autoDetectImageFormat) { + Q_ASSERT(qobject_cast<QFile*>(device) != 0); // future-proofing; for now this should always be the case, so... + QFile *file = static_cast<QFile *>(device); + + if (file->error() == QFileDevice::ResourceError) { + // this is bad. we should abort the open attempt and note the failure. + imageReaderError = QImageReader::DeviceError; + errorString = file->errorString(); + return false; + } + QList<QByteArray> extensions = QImageReader::supportedImageFormats(); if (!format.isEmpty()) { // Try the most probable extension first @@ -575,7 +585,6 @@ bool QImageReaderPrivate::initHandler() int currentExtension = 0; - QFile *file = static_cast<QFile *>(device); QString fileName = file->fileName(); do { |