[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

gEDA-cvs: gaf.git: branch: master updated (1.5.2-20090328-161-gc8628e4)



The branch, master has been updated
       via  c8628e4df819998e40d7954c5a5d41a2fbfbbb7d (commit)
      from  c3caf76d1ea789e82b67458d593ea6d3a7b8f275 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


=========
 Summary
=========

 libgeda/src/o_text_basic.c |   33 +++++++++++++++++++++------------
 1 files changed, 21 insertions(+), 12 deletions(-)


=================
 Commit Messages
=================

commit c8628e4df819998e40d7954c5a5d41a2fbfbbb7d
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>

    libgeda: Fix font loading.
    
    Fixes a bug introduced in 8af5fba2ec0248331ceb5d2746771e70b2813004
    which caused libgeda to not detect character widths correctly.
    
    This was subtle.  A new font OBJECT must be created and added to the
    global character hashtable *before* o_read() is called to populate the
    OBJECT with its constituent lines.  This is because when o_read()
    encounters the 'F' font parameter line, it calls
    o_text_set_info_font() to process it.  o_text_set_info_font() in turn
    needs to be able to get at the font object for that character, which
    it looks for using the global hashtable.
    
    I have added some comments to the source code explaining this.

:100644 100644 4a27e8a... c096d74... M	libgeda/src/o_text_basic.c

=========
 Changes
=========

commit c8628e4df819998e40d7954c5a5d41a2fbfbbb7d
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>

    libgeda: Fix font loading.
    
    Fixes a bug introduced in 8af5fba2ec0248331ceb5d2746771e70b2813004
    which caused libgeda to not detect character widths correctly.
    
    This was subtle.  A new font OBJECT must be created and added to the
    global character hashtable *before* o_read() is called to populate the
    OBJECT with its constituent lines.  This is because when o_read()
    encounters the 'F' font parameter line, it calls
    o_text_set_info_font() to process it.  o_text_set_info_font() in turn
    needs to be able to get at the font object for that character, which
    it looks for using the global hashtable.
    
    I have added some comments to the source code explaining this.

diff --git a/libgeda/src/o_text_basic.c b/libgeda/src/o_text_basic.c
index 4a27e8a..c096d74 100644
--- a/libgeda/src/o_text_basic.c
+++ b/libgeda/src/o_text_basic.c
@@ -366,8 +366,20 @@ GList *o_text_load_font (TOPLEVEL *toplevel, gunichar needed_char)
     found = FALSE;
   }
 
+  /* We need to make sure to create and add a font OBJECT to the
+   * font_loaded hashtable *before* attempting to call o_read().  This
+   * is because o_text_set_info_font() expects to find it. */
+  o_font_set = (OBJECT*)g_new (OBJECT, 1);
+  o_font_set->font_prim_objs = NULL;
+  o_font_set->font_text_size = 100;
+
+  /* Add it to the list and hash table. Some functions will need it */
+  g_hash_table_insert (font_loaded,
+                       GUINT_TO_POINTER (needed_char), o_font_set);
+
   if (found) {
-    prim_objs = o_read(toplevel, prim_objs, temp_string, &err);
+    o_font_set->font_prim_objs = o_read(toplevel, o_font_set->font_prim_objs,
+                                        temp_string, &err);
     if (err != NULL) {
       g_warning ("o_text_basic.c: Failed to read font file: %s\n",
                  err->message);
@@ -377,21 +389,18 @@ GList *o_text_load_font (TOPLEVEL *toplevel, gunichar needed_char)
   }
 
   if (!found) {
-    /* Get a question mark. */
-    o_font_set = builtin_question_mark (toplevel);
-  } else {
-    /* Make new object for the font set list */
-    o_font_set = (OBJECT*)g_new (OBJECT, 1);
-    o_font_set->font_prim_objs = prim_objs;
-    o_font_set->font_text_size = 100;
+    /* Get a question mark instead. */
+    OBJECT *q = builtin_question_mark (toplevel);
+    /* Replace the current o_font_set object in the hashtable.
+     * Because its font_prim_objs GList will be empty (== NULL), we
+     * can just rely on the hashtables free func to clean it up for
+     * us.  This is horrible, but effective. */
+    g_hash_table_insert (font_loaded, GUINT_TO_POINTER (needed_char), q);
+    o_font_set = q;
   }
 
   o_font_set->name = g_strdup_printf ("%c", needed_char);
 
-  /* Add it to the list and hash table. Some functions will need it */
-  g_hash_table_insert (font_loaded,
-                       GUINT_TO_POINTER (needed_char), o_font_set);
-
   g_free(temp_string);
 
   return(o_font_set->font_prim_objs);




_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs