aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2019-10-25 15:09:30 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2019-10-25 15:28:04 +0200
commit83a61c9f69a4c5571b9994de1696df264d403df4 (patch)
tree3315a2249dc31fa7ce79bc5b384a6eed01310358 /src
parent787d1b2e2a4acea6d2477a3197b757945614203e (diff)
Fix assertion with certain Text items when rendering with Metal
Caused by a -1 vs. 0 discrepancy between the QRhi and the OpenGL glyph caches. width() and height() are expected to return 0 for an empty image, but this we forgot to honor in the QRhi version. That returned the width or height of a QSize, and those are -1 when default constructed. (there are good reasons for that, it just happens to not match the non-QSize-based code path here) Change-Id: Idda0d2f77430abea79d4004b765077032e06954b Fixes: QTBUG-79533 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/quick/scenegraph/qsgrhitextureglyphcache_p.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/quick/scenegraph/qsgrhitextureglyphcache_p.h b/src/quick/scenegraph/qsgrhitextureglyphcache_p.h
index a7374d91a4..49854a596e 100644
--- a/src/quick/scenegraph/qsgrhitextureglyphcache_p.h
+++ b/src/quick/scenegraph/qsgrhitextureglyphcache_p.h
@@ -75,8 +75,10 @@ public:
QRhiTexture *texture() const { return m_texture; }
void commitResourceUpdates(QRhiResourceUpdateBatch *mergeInto);
- int width() const { return m_size.width(); }
- int height() const { return m_size.height(); }
+ // Clamp the default -1 width and height to 0 for compatibility with
+ // QOpenGLTextureGlyphCache.
+ int width() const { return qMax(0, m_size.width()); }
+ int height() const { return qMax(0, m_size.height()); }
bool eightBitFormatIsAlphaSwizzled() const;