Fix crash when trying to allocate in a filled atlas texture

Atlas::create returns null when allocating space in the atlas texture
fails, including when the texture is full. Manager::create assumed that
this function would never fail.

Change-Id: I2ed8a1b94640d6a3cc65011e83b88f8bd42ca074
Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
This commit is contained in:
John Brooks 2016-10-26 13:20:21 -06:00 committed by John Brooks
parent c849f3a7ef
commit af9f8ffb47
1 changed files with 2 additions and 1 deletions

View File

@ -110,8 +110,9 @@ QSGTexture *Manager::create(const QImage &image, bool hasAlphaChannel)
if (image.width() < m_atlas_size_limit && image.height() < m_atlas_size_limit) {
if (!m_atlas)
m_atlas = new Atlas(m_atlas_size);
// t may be null for atlas allocation failure
t = m_atlas->create(image);
if (!hasAlphaChannel && t->hasAlphaChannel())
if (t && !hasAlphaChannel && t->hasAlphaChannel())
t->setHasAlphaChannel(false);
}
return t;