Skip to content

Commit

Permalink
Fix potentially evicting glyphs in use during try_allocate
Browse files Browse the repository at this point in the history
  • Loading branch information
hecrj authored and grovesNL committed Jul 4, 2023
1 parent bc9cc82 commit 7f31965
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/text_atlas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,19 @@ impl InnerAtlas {
// Try to free least recently used allocation
let (mut key, mut value) = self.glyph_cache.peek_lru()?;

// Find a glyph with an actual size
while value.atlas_id.is_none() {
// All sized glyphs are in use, cache is full
if self.glyphs_in_use.contains(&key) {
return None;
}

let _ = self.glyph_cache.pop_lru();

(key, value) = self.glyph_cache.peek_lru()?;
}

// All sized glyphs are in use, cache is full
if self.glyphs_in_use.contains(&key) {
return None;
}
Expand Down

0 comments on commit 7f31965

Please sign in to comment.