From 83a61c9f69a4c5571b9994de1696df264d403df4 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Fri, 25 Oct 2019 15:09:30 +0200 Subject: 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 --- src/quick/scenegraph/qsgrhitextureglyphcache_p.h | 6 ++++-- 1 file 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; -- cgit v1.2.3