segmentation violation when clicking on Edit/Preferences/Appearance/Fonts
patch by sergei_d@fi.tartu.ee (Sergei Dolgov) r=biesi (beos only, no sr needed)
This commit is contained in:
cbiesinger%web.de 2004-01-21 20:23:15 +00:00
Родитель 345194dd62
Коммит 00e4a35da2
1 изменённых файлов: 15 добавлений и 9 удалений

Просмотреть файл

@ -428,6 +428,8 @@ NS_IMETHODIMP nsFontMetricsBeOS::GetFontHandle(nsFontHandle &aHandle)
nsresult
nsFontMetricsBeOS::FamilyExists(const nsString& aName)
{
//Do we really need it here? BeOS supports UTF-8 overall natively,
//including UTF-8 fonts names with non-ascii chars inside
if (!IsASCII(aName))
return NS_ERROR_FAILURE;
@ -482,6 +484,10 @@ static int
FontMatchesGenericType(font_family family, uint32 flags, const char* aGeneric,
const char* aLangGroup)
{
//Call from EnumerateAllFonts. Matches all.
//Return 1 immediately, because nsnull as argument of strstr causes crashes
if(aGeneric == nsnull || aLangGroup == nsnull)
return 1;
if (!strcmp(aLangGroup, "ja"))
return 1;
if (strstr(aLangGroup, "zh"))
@ -606,17 +612,17 @@ static nsresult EnumFonts(const char * aLangGroup, const char* aGeneric, PRUint3
uint32 flags;
if (get_font_family(i, &family, &flags) == B_OK)
{
if (family &&
(!aLangGroup ||
FontMatchesGenericType(family, flags, aGeneric, aLangGroup) &&
MatchesLangGroup(family, aLangGroup)))
if (family && (!aLangGroup || MatchesLangGroup(family, aLangGroup)))
{
font_name.AssignWithConversion(family);
if (!(array[j] = ToNewUnicode(font_name)))
break;
++j;
if(FontMatchesGenericType(family, flags, aGeneric, aLangGroup))
{
font_name.AssignWithConversion(family);
if (!(array[j] = ToNewUnicode(font_name)))
break;
++j;
}
}
}
}
}
NS_QuickSort(array, j, sizeof(PRUnichar*), CompareFontNames, nsnull);