summaryrefslogtreecommitdiffstats
path: root/src/opengl
diff options
context:
space:
mode:
authorJani Hautakangas <jani.hautakangas@nokia.com>2011-02-09 10:49:13 (GMT)
committerJani Hautakangas <jani.hautakangas@nokia.com>2011-02-09 11:06:43 (GMT)
commitea770c9aa3099facd7adccf5d4a159bc163e7356 (patch)
tree085cdbdfc1b5868f419924c45dfa759060375452 /src/opengl
parentbf1cb011f23f1779fccd8c911afbdc5765fb316d (diff)
downloadQt-ea770c9aa3099facd7adccf5d4a159bc163e7356.zip
Qt-ea770c9aa3099facd7adccf5d4a159bc163e7356.tar.gz
Qt-ea770c9aa3099facd7adccf5d4a159bc163e7356.tar.bz2
Fix for loading QPixmaps from file in GL graphics system
QPixmap::load fails if extension (.png) is left out from given filename when loading a pixmap. QPixmap should try loading with all supported formats. Task-number: QTBUG-17328 Reviewed-by: Samuel Rødal
Diffstat (limited to 'src/opengl')
-rw-r--r--src/opengl/qpixmapdata_gl.cpp44
1 files changed, 22 insertions, 22 deletions
diff --git a/src/opengl/qpixmapdata_gl.cpp b/src/opengl/qpixmapdata_gl.cpp
index 249c71e..72035bd 100644
--- a/src/opengl/qpixmapdata_gl.cpp
+++ b/src/opengl/qpixmapdata_gl.cpp
@@ -390,29 +390,29 @@ bool QGLPixmapData::fromFile(const QString &filename, const char *format,
if (pixelType() == QPixmapData::BitmapType)
return QPixmapData::fromFile(filename, format, flags);
QFile file(filename);
- if (!file.open(QIODevice::ReadOnly))
- return false;
- QByteArray data = file.peek(64);
- bool alpha;
- if (m_texture.canBindCompressedTexture
- (data.constData(), data.size(), format, &alpha)) {
- resize(0, 0);
- data = file.readAll();
- file.close();
- QGLShareContextScope ctx(qt_gl_share_context());
- QSize size = m_texture.bindCompressedTexture
- (data.constData(), data.size(), format);
- if (!size.isEmpty()) {
- w = size.width();
- h = size.height();
- is_null = false;
- d = 32;
- m_hasAlpha = alpha;
- m_source = QImage();
- m_dirty = isValid();
- return true;
+ if (file.open(QIODevice::ReadOnly)) {
+ QByteArray data = file.peek(64);
+ bool alpha;
+ if (m_texture.canBindCompressedTexture
+ (data.constData(), data.size(), format, &alpha)) {
+ resize(0, 0);
+ data = file.readAll();
+ file.close();
+ QGLShareContextScope ctx(qt_gl_share_context());
+ QSize size = m_texture.bindCompressedTexture
+ (data.constData(), data.size(), format);
+ if (!size.isEmpty()) {
+ w = size.width();
+ h = size.height();
+ is_null = false;
+ d = 32;
+ m_hasAlpha = alpha;
+ m_source = QImage();
+ m_dirty = isValid();
+ return true;
+ }
+ return false;
}
- return false;
}
QImage image = QImageReader(filename, format).read();