]> git.lyx.org Git - features.git/commitdiff
Do not crash is release mode if we stumble across an unrealized font.
authorRichard Heck <rgheck@lyx.org>
Mon, 18 Jul 2016 17:01:42 +0000 (13:01 -0400)
committerRichard Heck <rgheck@lyx.org>
Mon, 18 Jul 2016 17:03:47 +0000 (13:03 -0400)
(cherry picked from commit 3203fb1c5fcfa8e1b3c4e4e802c18241bdbc4272)

src/frontends/qt4/GuiFontLoader.cpp
status.22x

index 9a662a893b3ce846386588370befeeaeae755f15..148677b5fb4f10848c558584033ae01423b44b38 100644 (file)
@@ -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 =
index 5afab3f25738b85bd43162e1b68436beab07564f..772b504df5d539aee2c12fe7096d4804fbe6df60 100644 (file)
@@ -40,6 +40,8 @@ What's new
 
 * USER INTERFACE
 
+- Avoid crashing in release mode if we stumble across an unrealized font.
+
 - Fix display of citations with two authors. 
 
 - Fix display of multi-author citations when the GUI language is not English.