diff options
Diffstat (limited to 'src/gui/image')
-rw-r--r-- | src/gui/image/qpicture.cpp | 4 | ||||
-rw-r--r-- | src/gui/image/qpixmap.cpp | 10 | ||||
-rw-r--r-- | src/gui/image/qpnghandler.cpp | 6 | ||||
-rw-r--r-- | src/gui/image/qxbmhandler.cpp | 4 |
4 files changed, 15 insertions, 9 deletions
diff --git a/src/gui/image/qpicture.cpp b/src/gui/image/qpicture.cpp index 6e57f679d8..56b82abcfa 100644 --- a/src/gui/image/qpicture.cpp +++ b/src/gui/image/qpicture.cpp @@ -1866,7 +1866,7 @@ QList<QByteArray> QPictureIO::outputFormats() bool QPictureIO::read() { QFile file; - const char *picture_format; + QByteArray picture_format; QPictureHandler *h; if (d->iodev) { // read from io device @@ -1882,7 +1882,7 @@ bool QPictureIO::read() if (d->frmt.isEmpty()) { // Try to guess format picture_format = pictureFormat(d->iodev); // get picture format - if (!picture_format) { + if (picture_format.isEmpty()) { if (file.isOpen()) { // unknown format file.close(); d->iodev = 0; diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp index 1ec4e3488a..2ef1d09422 100644 --- a/src/gui/image/qpixmap.cpp +++ b/src/gui/image/qpixmap.cpp @@ -714,8 +714,8 @@ QBitmap QPixmap::createMaskFromColor(const QColor &maskColor, Qt::MaskMode mode) control the conversion. Note that QPixmaps are automatically added to the QPixmapCache - when loaded from a file; the key used is internal and can not - be acquired. + when loaded from a file in main thread; the key used is internal + and cannot be acquired. \sa loadFromData(), {QPixmap#Reading and Writing Image Files}{Reading and Writing Image Files} @@ -729,6 +729,7 @@ bool QPixmap::load(const QString &fileName, const char *format, Qt::ImageConvers // Note: If no extension is provided, we try to match the // file against known plugin extensions if (info.completeSuffix().isEmpty() || info.exists()) { + const bool inGuiThread = qApp->thread() == QThread::currentThread(); QString key = QLatin1String("qt_pixmap") % info.absoluteFilePath() @@ -736,13 +737,14 @@ bool QPixmap::load(const QString &fileName, const char *format, Qt::ImageConvers % HexString<quint64>(info.size()) % HexString<uint>(data ? data->pixelType() : QPlatformPixmap::PixmapType); - if (QPixmapCache::find(key, this)) + if (inGuiThread && QPixmapCache::find(key, this)) return true; data = QPlatformPixmap::create(0, 0, data ? data->pixelType() : QPlatformPixmap::PixmapType); if (data->fromFile(fileName, format, flags)) { - QPixmapCache::insert(key, *this); + if (inGuiThread) + QPixmapCache::insert(key, *this); return true; } } diff --git a/src/gui/image/qpnghandler.cpp b/src/gui/image/qpnghandler.cpp index 3655c39326..1a5e7718eb 100644 --- a/src/gui/image/qpnghandler.cpp +++ b/src/gui/image/qpnghandler.cpp @@ -233,8 +233,8 @@ void setup_qt(QImage& image, png_structp png_ptr, png_infop info_ptr, QSize scal png_uint_32 width; png_uint_32 height; - int bit_depth; - int color_type; + int bit_depth = 0; + int color_type = 0; png_bytep trans_alpha = 0; png_color_16p trans_color_p = 0; int num_trans; @@ -690,7 +690,7 @@ QImage::Format QPngHandlerPrivate::readImageFormat() { QImage::Format format = QImage::Format_Invalid; png_uint_32 width, height; - int bit_depth, color_type; + int bit_depth = 0, color_type = 0; png_colorp palette; int num_palette; png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, 0, 0, 0); diff --git a/src/gui/image/qxbmhandler.cpp b/src/gui/image/qxbmhandler.cpp index 24d86e116d..7ba44049b4 100644 --- a/src/gui/image/qxbmhandler.cpp +++ b/src/gui/image/qxbmhandler.cpp @@ -97,6 +97,8 @@ static bool read_xbm_header(QIODevice *device, int& w, int& h) if (r1.indexIn(sbuf) == 0 && r2.indexIn(sbuf, r1.matchedLength()) == r1.matchedLength()) w = QByteArray(&buf[r1.matchedLength()]).trimmed().toInt(); + else + return false; // "#define .._height <num>" readBytes = device->readLine(buf, buflen); @@ -109,6 +111,8 @@ static bool read_xbm_header(QIODevice *device, int& w, int& h) if (r1.indexIn(sbuf) == 0 && r2.indexIn(sbuf, r1.matchedLength()) == r1.matchedLength()) h = QByteArray(&buf[r1.matchedLength()]).trimmed().toInt(); + else + return false; // format error if (w <= 0 || w > 32767 || h <= 0 || h > 32767) |