Revert changes made to FcConfigAppFontAddDir() recently

In 32ac7c75e8 the behavior of
FcConfigAppFontAddFile/Dir() were changed to return false
if not fonts were found.  While this is welldefined and useful
for AddFile(), it's quite problematic for AddDir().  For example,
if the directory is empty, is that a failure or success?  Worse,
the false value from AddDir() was being propagated all the way
to FcInit() returning false now.  This only happened upon memory
allocation failure before, and some clients assert that FcInit()
is successful.

With this change, AddDir() is reverted back to what it was.
AddFont() change (which was actually in fcdir.c) from the original
commit is left in.
This commit is contained in:
Behdad Esfahbod 2015-06-26 17:02:13 -07:00
parent a8096dfa59
commit 46ec6a52d4
4 changed files with 12 additions and 30 deletions

View File

@ -232,7 +232,7 @@ the current configuration is used.
@DESC@
Scans the specified directory for fonts, adding each one found to the
application-specific set of fonts. Returns FcFalse
if the fonts cannot be added (due to allocation failure or no fonts found).
if the fonts cannot be added (due to allocation failure).
Otherwise returns FcTrue. If <parameter>config</parameter> is NULL,
the current configuration is used.
@@

View File

@ -368,13 +368,10 @@ FcConfigAddDirList (FcConfig *config, FcSetName set, FcStrSet *dirSet)
FcStrList *dirlist;
FcChar8 *dir;
FcCache *cache;
FcBool ret = FcFalse;
dirlist = FcStrListCreate (dirSet);
if (!dirlist)
return FcFalse;
if (FcStrListGetLength (dirlist) == 0)
ret = FcTrue;
while ((dir = FcStrListNext (dirlist)))
{
@ -385,10 +382,9 @@ FcConfigAddDirList (FcConfig *config, FcSetName set, FcStrSet *dirSet)
continue;
FcConfigAddCache (config, cache, set, dirSet);
FcDirCacheUnload (cache);
ret = FcTrue;
}
FcStrListDone (dirlist);
return ret;
return FcTrue;
}
/*
@ -2201,7 +2197,6 @@ FcConfigAppFontAddFile (FcConfig *config,
FcStrSet *subdirs;
FcStrList *sublist;
FcChar8 *subdir;
FcBool ret = FcFalse;
if (!config)
{
@ -2231,19 +2226,16 @@ FcConfigAppFontAddFile (FcConfig *config,
FcStrSetDestroy (subdirs);
return FcFalse;
}
if (subdirs->num == 0)
ret = FcTrue;
else if ((sublist = FcStrListCreate (subdirs)))
if ((sublist = FcStrListCreate (subdirs)))
{
while ((subdir = FcStrListNext (sublist)))
{
if (FcConfigAppFontAddDir (config, subdir))
ret = FcTrue;
FcConfigAppFontAddDir (config, subdir);
}
FcStrListDone (sublist);
}
FcStrSetDestroy (subdirs);
return ret;
return FcTrue;
}
FcBool
@ -2252,7 +2244,6 @@ FcConfigAppFontAddDir (FcConfig *config,
{
FcFontSet *set;
FcStrSet *dirs;
FcBool ret = FcTrue;
if (!config)
{
@ -2271,8 +2262,8 @@ FcConfigAppFontAddDir (FcConfig *config,
set = FcFontSetCreate ();
if (!set)
{
ret = FcFalse;
goto bail;
FcStrSetDestroy (dirs);
return FcFalse;
}
FcConfigSetFonts (config, set, FcSetApplication);
}
@ -2280,10 +2271,12 @@ FcConfigAppFontAddDir (FcConfig *config,
FcStrSetAddFilename (dirs, dir);
if (!FcConfigAddDirList (config, FcSetApplication, dirs))
ret = FcFalse;
bail:
{
FcStrSetDestroy (dirs);
return ret;
return FcFalse;
}
FcStrSetDestroy (dirs);
return FcTrue;
}
void

View File

@ -1176,9 +1176,6 @@ FcStrSerializeAlloc (FcSerialize *serialize, const FcChar8 *str);
FcPrivate FcChar8 *
FcStrSerialize (FcSerialize *serialize, const FcChar8 *str);
FcPrivate int
FcStrListGetLength (const FcStrList *list);
/* fcobjs.c */
FcPrivate void

View File

@ -1347,14 +1347,6 @@ FcStrListDone (FcStrList *list)
free (list);
}
int
FcStrListGetLength (const FcStrList *list)
{
if (!list)
return 0;
return list->set->num;
}
#define __fcstr__
#include "fcaliastail.h"
#undef __fcstr__