Bug 1198921 - Add a null-check after cairo_get_scaled_font in GetRoundOffsetsToPixels. r=m_kato, a=ritu
authorJohn Daggett <jdaggett@mozilla.com>
Thu, 27 Aug 2015 13:23:52 +0900
changeset 289062 55dae3e3f058b91e85c1cd427a06a62aacc8abb3
parent 289061 964c244342551dec7db357aa37bf156307ba18bd
child 289063 ca0ab2a3305b0b62a58b2803df024251256f3623
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersm_kato, ritu
bugs1198921
milestone42.0a2
Bug 1198921 - Add a null-check after cairo_get_scaled_font in GetRoundOffsetsToPixels. r=m_kato, a=ritu
gfx/thebes/gfxContext.cpp
--- a/gfx/thebes/gfxContext.cpp
+++ b/gfx/thebes/gfxContext.cpp
@@ -1365,16 +1365,25 @@ gfxContext::GetRoundOffsetsToPixels(bool
     }
 
     // All raster backends snap glyphs to pixels vertically.
     // Print backends set CAIRO_HINT_METRICS_OFF.
     *aRoundY = true;
 
     cairo_t *cr = GetCairo();
     cairo_scaled_font_t *scaled_font = cairo_get_scaled_font(cr);
+
+    // bug 1198921 - this sometimes fails under Windows for whatver reason
+    NS_ASSERTION(scaled_font, "null cairo scaled font should never be returned "
+                 "by cairo_get_scaled_font");
+    if (!scaled_font) {
+        *aRoundX = true; // default to the same as the fallback path below
+        return;
+    }
+
     // Sometimes hint metrics gets set for us, most notably for printing.
     cairo_font_options_t *font_options = cairo_font_options_create();
     cairo_scaled_font_get_font_options(scaled_font, font_options);
     cairo_hint_metrics_t hint_metrics =
         cairo_font_options_get_hint_metrics(font_options);
     cairo_font_options_destroy(font_options);
 
     switch (hint_metrics) {