diff options
authorEskil Abrahamsen Blomfeldt <>2019-06-20 10:26:38 +0200
committerEskil Abrahamsen Blomfeldt <>2019-06-20 10:56:43 +0200
commita05eb132416fcce8eb6a9fb240d0867796ed9deb (patch)
parentd7e346b58260b24e02c64f82b2900bfba5951330 (diff)
distancefieldgenerator: Fix crash with multiple textures
We need to make sure the allocated area starts at (0,0), since we allocate a texture at [width x height], and this would be too small if it did not also account for possible gaps at the top of the cache. This happens because glyphs may sometimes end up at the edge between two textures, in which case we will reserve space for them in the second of the two even though this is not needed. So this is a deficiency in the cache logic itself, but we need to at least make sure it does not crash. [ChangeLog][distancefieldgenerator] Fixed possible crash when generating large number of glyphs with a small texture size. Task-number: QTBUG-76188 Task-number: QTBUG-76528 Change-Id: I84c87c72985f5b621d120e7526cfe071555fa7f8 Reviewed-by: Simon Hausmann <>
1 files changed, 3 insertions, 3 deletions
diff --git a/src/distancefieldgenerator/mainwindow.cpp b/src/distancefieldgenerator/mainwindow.cpp
index 94f5c8ebb..3717330b4 100644
--- a/src/distancefieldgenerator/mainwindow.cpp
+++ b/src/distancefieldgenerator/mainwindow.cpp
@@ -488,14 +488,14 @@ QByteArray MainWindow::createSfntTable()
glyphData.textureIndex = rect.y() / textureSize;
- if (glyphData.textureIndex >= allocatedAreaPerTexture.size())
- allocatedAreaPerTexture.resize(glyphData.textureIndex + 1);
+ while (glyphData.textureIndex >= allocatedAreaPerTexture.size())
+ allocatedAreaPerTexture.append(QRect(0, 0, 1, 1));
allocatedAreaPerTexture[glyphData.textureIndex] |= QRect(rect.x(),
rect.y() % textureSize,
glyphData.texCoord.xMargin = QT_DISTANCEFIELD_RADIUS(m_model->doubleGlyphResolution()) / qreal(QT_DISTANCEFIELD_SCALE(m_model->doubleGlyphResolution()));
glyphData.texCoord.yMargin = QT_DISTANCEFIELD_RADIUS(m_model->doubleGlyphResolution()) / qreal(QT_DISTANCEFIELD_SCALE(m_model->doubleGlyphResolution()));
glyphData.texCoord.x = rect.x() + padding;