Commits

Anonymous committed 6136e1f

EXT-1279 Crash if font file not found.
Added getFontDefault() to llfontgl.h

  • Participants
  • Parent commits 2fdb664
  • Branches branch-test

Comments (0)

Files changed (6)

indra/llrender/llfontgl.cpp

 	}
 }
 
+//static
+LLFontGL* LLFontGL::getFontDefault()
+{
+	return getFontSansSerif(); // Fallback to sans serif as default font
+}
+
+
 // static 
 std::string LLFontGL::getFontPathSystem()
 {

indra/llrender/llfontgl.h

 	static LLFontGL* getFont(const LLFontDescriptor& desc);
 	// Use with legacy names like "SANSSERIF_SMALL" or "OCRA"
 	static LLFontGL* getFontByName(const std::string& name);
+	static LLFontGL* getFontDefault(); // default fallback font
 
 	static std::string getFontPathLocal();
 	static std::string getFontPathSystem();

indra/llrender/llfontregistry.cpp

 	LLFontDescriptor nearest_exact_desc = *match_desc;
 	nearest_exact_desc.setSize(norm_desc.getSize());
 	font_reg_map_t::iterator it = mFontMap.find(nearest_exact_desc);
-	if (it != mFontMap.end())
+	// If we fail to find a font in the fonts directory, it->second might be NULL.
+	// We shouldn't construcnt a font with a NULL mFontFreetype.
+	// This may not be the best solution, but it at least prevents a crash.
+	if (it != mFontMap.end() && it->second != NULL)
 	{
 		llinfos << "-- matching font exists: " << nearest_exact_desc.getName() << " size " << nearest_exact_desc.getSize() << " style " << ((S32) nearest_exact_desc.getStyle()) << llendl;
 		

indra/llui/llconsole.cpp

 	{
 		mFont = LLFontGL::getFontSansSerifHuge();
 	}
+	// Make sure the font exists
+	if (mFont == NULL)
+	{
+		mFont = LLFontGL::getFontDefault();
+	}
 	
 	for(paragraph_t::iterator paragraph_it = mParagraphs.begin(); paragraph_it != mParagraphs.end(); paragraph_it++)
 	{

indra/llui/llui.cpp

 				return fontp;
 			}
 		}
-
+		
+		if (mData.mValue == NULL)
+		{
+			mData.mValue = LLFontGL::getFontDefault();
+		}
+		
 		// default to current value
 		return mData.mValue;
 	}

indra/newview/llfolderviewitem.cpp

 	{
 		LLFontDescriptor labelfontdesc("SansSerif", "Small", style);
 		rtn = LLFontGL::getFont(labelfontdesc);
+		if (!rtn)
+		{
+			rtn = LLFontGL::getFontDefault();
+		}
 		sFonts[style] = rtn;
 	}
 	return rtn;