]> git.wh0rd.org - fontconfig.git/commitdiff
Don't zero out full names for FC_REF_CONSTANT fonts; also, duplicate full
authorPatrick Lam <plam@MIT.EDU>
Wed, 2 Nov 2005 15:29:53 +0000 (15:29 +0000)
committerPatrick Lam <plam@MIT.EDU>
Wed, 2 Nov 2005 15:29:53 +0000 (15:29 +0000)
    names when transferring, and free full names when freeing the
    associated font. Reported by Jinghua Luo.

ChangeLog
src/fcpat.c

index 58148927d40c61dcedee2109da773bb6c16e4126..7c45d3dd603f6ad6a11130178c91817d47574590 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2005-11-02  Patrick Lam  <plam@mit.edu>
+       * src/fcpat.c (FcPatternDestroy, FcPatternTransferFullName):
+
+       Don't zero out full names for FC_REF_CONSTANT fonts;
+       also, duplicate full names when transferring, and free
+       full names when freeing the associated font.
+       Reported by Jinghua Luo.
+
 2005-11-02  Patrick Lam  <plam@mit.edu>
        * fc-cache/fc-cache.c (scanDirs):
        * src/fcpat.c (FcValueListSerialize):
index fa63ea3189a1bb2a3da6c706948eb38d874d3d65..4dc5e4b7bc15843e8d9c5d37012bae1258d2b2dc 100644 (file)
@@ -39,6 +39,13 @@ FcPatternFindFullFname (const FcPattern *p);
 static FcPatternEltPtr
 FcPatternEltPtrCreateDynamic (FcPatternElt * e);
 
+/* If you are trying to duplicate an FcPattern which will be used for
+ * rendering, be aware that (internally) you also have to use
+ * FcPatternTransferFullFname to transfer the associated filename.  If
+ * you are copying the font (externally) using FcPatternGetString,
+ * then everything's fine; this caveat only applies if you're copying
+ * the bits individually.  */
+
 FcPattern *
 FcPatternCreate (void)
 {
@@ -297,12 +304,15 @@ FcPatternDestroy (FcPattern *p)
 {
     int                    i;
     
-    if (FcPatternFindFullFname (p))
-       FcPatternAddFullFname (p, 0);
-
     if (p->ref == FC_REF_CONSTANT || --p->ref > 0)
        return;
 
+    if (FcPatternFindFullFname (p))
+    {
+       FcStrFree (FcPatternFindFullFname (p));
+       FcPatternAddFullFname (p, 0);
+    }
+
     for (i = 0; i < p->num; i++)
        FcValueListDestroy ((FcPatternEltU(p->elts)+i)->values);
 
@@ -1993,5 +2003,5 @@ FcPatternTransferFullFname (const FcPattern *new, const FcPattern *orig)
 {
     FcChar8 * s;
     FcPatternGetString (orig, FC_FILE, 0, &s);
-    FcPatternAddFullFname (new, FcPatternFindFullFname(orig));
+    FcPatternAddFullFname (new, FcStrCopy (FcPatternFindFullFname(orig)));
 }