From 3203fb1c5fcfa8e1b3c4e4e802c18241bdbc4272 Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Mon, 18 Jul 2016 13:01:42 -0400 Subject: [PATCH] Do not crash is release mode if we stumble across an unrealized font. --- src/frontends/qt4/GuiFontLoader.cpp | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/frontends/qt4/GuiFontLoader.cpp b/src/frontends/qt4/GuiFontLoader.cpp index 9a662a893b..148677b5fb 100644 --- a/src/frontends/qt4/GuiFontLoader.cpp +++ b/src/frontends/qt4/GuiFontLoader.cpp @@ -95,11 +95,24 @@ static GuiFontInfo * fontinfo_[NUM_FAMILIES][NUM_SERIES][NUM_SHAPE][NUM_SIZE]; // if not cached, create it. GuiFontInfo & fontinfo(FontInfo const & f) { - // LASSERT: Is there anything we might do here besides crash? - LBUFERR(f.family() < NUM_FAMILIES); - LBUFERR(f.series() < NUM_SERIES); - LBUFERR(f.realShape() < NUM_SHAPE); - LBUFERR(f.size() < NUM_SIZE); + bool const fontIsRealized = + (f.family() < NUM_FAMILIES) && + (f.series() < NUM_SERIES) && + (f.realShape() < NUM_SHAPE) && + (f.size() < NUM_SIZE); + if (!fontIsRealized) { + // We can reset the font to something sensible in release mode. + LATTEST(false); + LYXERR0("Unrealized font!"); + // We could be fancier here, if we wanted, and just fix things where + // there is a problem. But it doesn't seem worth it, since we should + // not be here in the first place. + GuiFontInfo * & fi = + fontinfo_[sane_font.family()][sane_font.series()][sane_font.realShape()][sane_font.size()]; + if (!fi) + fi = new GuiFontInfo(f); + return *fi; + } // fi is a reference to the pointer type (GuiFontInfo *) in the // fontinfo_ table. GuiFontInfo * & fi = -- 2.39.2