From f2ae2ce3aca890ef7ecd104fc9416bdc92042b5f Mon Sep 17 00:00:00 2001 From: Lee Salzman Date: Tue, 5 Sep 2017 17:07:32 -0400 Subject: [PATCH] don't panic when an invalid font instance key is supplied --- webrender/src/frame.rs | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/webrender/src/frame.rs b/webrender/src/frame.rs index 6ca3f3cb7b..d8fcc81db9 100644 --- a/webrender/src/frame.rs +++ b/webrender/src/frame.rs @@ -567,16 +567,22 @@ impl Frame { info.image_rendering); } SpecificDisplayItem::Text(ref text_info) => { - let instance = context.resource_cache.get_font_instance(text_info.font_key).unwrap(); - context.builder.add_text(clip_and_scroll, - reference_frame_relative_offset, - item_rect_with_offset, - &clip_with_offset, - instance, - &text_info.color, - item.glyphs(), - item.display_list().get(item.glyphs()).count(), - text_info.glyph_options); + match context.resource_cache.get_font_instance(text_info.font_key) { + Some(instance) => { + context.builder.add_text(clip_and_scroll, + reference_frame_relative_offset, + item_rect_with_offset, + &clip_with_offset, + instance, + &text_info.color, + item.glyphs(), + item.display_list().get(item.glyphs()).count(), + text_info.glyph_options); + } + None => { + warn!("Unknown font instance key: {:?}", text_info.font_key); + } + } } SpecificDisplayItem::Rectangle(ref info) => { if !self.try_to_add_rectangle_splitting_on_clip(context,