Fix crash when Atlas is full

This fixes the regression introduced by 2d27fff.

Fixes #6688.
This commit is contained in:
Kirill Chibisov 2023-02-11 21:05:39 +03:00 committed by GitHub
parent 2d27fff796
commit 38e0b562a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -259,9 +259,13 @@ impl Atlas {
match atlas[*current_atlas].insert(rasterized, active_tex) {
Ok(glyph) => glyph,
Err(AtlasInsertError::Full) => {
// Get the context type before adding a new Atlas.
let is_gles_context = atlas[*current_atlas].is_gles_context;
// Advance the current Atlas index.
*current_atlas += 1;
if *current_atlas == atlas.len() {
let new = Atlas::new(ATLAS_SIZE, atlas[*current_atlas].is_gles_context);
let new = Atlas::new(ATLAS_SIZE, is_gles_context);
*active_tex = 0; // Atlas::new binds a texture. Ugh this is sloppy.
atlas.push(new);
}