[evolution-patches] [gtkhtml] various memeory leaks fix
- From: Radek Doulik <rodo ucw cz>
- To: Patches <evolution-patches ximian com>
- Cc: Rodrigo Moya <rodrigo novell com>, Rodney Dawes <dobey novell com>
- Subject: [evolution-patches] [gtkhtml] various memeory leaks fix
- Date: Mon, 11 Apr 2005 14:56:59 +0200
Index: components/html-editor/ChangeLog
===================================================================
RCS file: /cvs/gnome/gtkhtml/components/html-editor/ChangeLog,v
retrieving revision 1.493
diff -u -p -r1.493 ChangeLog
--- components/html-editor/ChangeLog 8 Apr 2005 12:33:42 -0000 1.493
+++ components/html-editor/ChangeLog 11 Apr 2005 12:37:47 -0000
@@ -1,3 +1,9 @@
+2005-04-11 Radek Doulik <rodo novell com>
+
+ * menubar.c (menubar_set_languages): free str when we don't need
+ it
+ (menubar_setup): free filename string
+
2005-04-07 Tor Lillqvist <tml novell com>
* Makefile.am (libgnome_gtkhtml_editor_3_8_la_LDFLAGS): Add
Index: components/html-editor/menubar.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/components/html-editor/menubar.c,v
retrieving revision 1.114
diff -u -p -r1.114 menubar.c
--- components/html-editor/menubar.c 28 Feb 2005 15:38:43 -0000 1.114
+++ components/html-editor/menubar.c 11 Apr 2005 12:37:50 -0000
@@ -657,6 +657,7 @@ menubar_set_languages (GtkHTMLControlDat
g_string_printf (str, "/commands/SpellLanguage%d", i + 1);
bonobo_ui_component_set_prop (cd->uic, str->str, "state", enabled ? "1" : "0", NULL);
}
+ g_string_free (str, TRUE);
cd->block_language_changes = FALSE;
}
@@ -783,6 +784,7 @@ menubar_setup (BonoboUIComponent *uic,
bonobo_ui_component_set_prop (uic, pixmaps_map [i].path, "pixname", filename, NULL);
} else
g_warning ("cannot find icon: '%s' in gnome icon theme", pixmaps_map [i].stock_name);
+ g_free (filename);
}
spell_create_language_menu (cd);
Index: src/ChangeLog
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/ChangeLog,v
retrieving revision 1.2115
diff -u -p -r1.2115 ChangeLog
--- src/ChangeLog 8 Apr 2005 14:37:37 -0000 1.2115
+++ src/ChangeLog 11 Apr 2005 12:39:03 -0000
@@ -1,3 +1,30 @@
+2005-04-11 Radek Doulik <rodo novell com>
+
+ * htmlundo.c (html_undo_destroy): destroy lists and levels as well
+ (level_destroy): use destroy_action_list
+
+ * htmltextslave.c (glyph_items_destroy): destroy only non NULL
+ glyph strings, fix list type
+ (get_glyph_items_in_range): destroy old list
+ (clear_glyph_items): cdestroy glyph items and not glyphs list
+ (destroy): destroy glyph items as well
+
+ * htmltext.c (html_text_get_attr_list_list): destroy iterator
+ (save): destroy iterator
+ (remove_one): destroy link when it's removed
+
+ * htmlinterval.c (do_downtree_lines_intersection): as bellow
+
+ * htmlengine-edit-movement.c
+ (html_engine_edit_cursor_position_restore): free the link once
+ it's removed
+
+ * htmlengine-edit-cut-and-paste.c (delete_object_do): destroy all
+ the lists
+ (insert_object_do): likewise
+
+ * gtkhtmldebug.c (gtk_html_debug_list_attrs): destroy iterator
+
2005-04-06 Radek Doulik <rodo novell com>
* added [un]block-selection commands. these are going to be used
Index: src/gtkhtmldebug.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/gtkhtmldebug.c,v
retrieving revision 1.50
diff -u -p -r1.50 gtkhtmldebug.c
--- src/gtkhtmldebug.c 3 Feb 2005 17:18:43 -0000 1.50
+++ src/gtkhtmldebug.c 11 Apr 2005 12:39:03 -0000
@@ -450,6 +450,8 @@ gtk_html_debug_list_attrs (PangoAttrList
D_ATTR_TYPE (SCALE, "Scale");
g_print ("------------\n");
} while (pango_attr_iterator_next (iter));
+
+ pango_attr_iterator_destroy (iter);
}
void
Index: src/htmlengine-edit-cut-and-paste.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmlengine-edit-cut-and-paste.c,v
retrieving revision 1.110
diff -u -p -r1.110 htmlengine-edit-cut-and-paste.c
--- src/htmlengine-edit-cut-and-paste.c 11 Mar 2005 15:24:29 -0000 1.110
+++ src/htmlengine-edit-cut-and-paste.c 11 Apr 2005 12:39:12 -0000
@@ -567,6 +567,12 @@ delete_object_do (HTMLEngine *e, HTMLObj
*object = html_object_op_cut (HTML_OBJECT (from->data), e, from->next, to->next, left, right, len);
position = e->cursor->position;
remove_empty_and_merge (e, TRUE, left ? left->next : NULL, right ? right->next : NULL, NULL);
+
+ g_list_free (from);
+ g_list_free (to);
+ g_list_free (left);
+ g_list_free (right);
+
e->cursor->position = position;
html_engine_spell_check_range (e, e->cursor, e->cursor);
html_engine_thaw (e);
@@ -875,6 +881,12 @@ insert_object_do (HTMLEngine *e, HTMLObj
#endif
remove_empty_and_merge (e, TRUE, last, right, orig);
remove_empty_and_merge (e, TRUE, left, first, orig);
+
+ g_list_free (first);
+ g_list_free (last);
+ g_list_free (left);
+ g_list_free (right);
+
#ifdef OP_DEBUG
printf ("position after merge %d\n", e->cursor->position);
#endif
Index: src/htmlengine-edit-movement.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmlengine-edit-movement.c,v
retrieving revision 1.20
diff -u -p -r1.20 htmlengine-edit-movement.c
--- src/htmlengine-edit-movement.c 25 Jan 2005 15:09:40 -0000 1.20
+++ src/htmlengine-edit-movement.c 11 Apr 2005 12:39:12 -0000
@@ -413,6 +413,8 @@ html_engine_edit_cursor_position_save (H
void
html_engine_edit_cursor_position_restore (HTMLEngine *e)
{
+ GSList *link;
+
g_return_if_fail (e != NULL);
g_return_if_fail (HTML_IS_ENGINE (e));
@@ -421,6 +423,8 @@ html_engine_edit_cursor_position_restore
html_engine_hide_cursor (e);
html_cursor_jump_to_position (e->cursor, e, GPOINTER_TO_INT (e->cursor_position_stack->data));
- e->cursor_position_stack = g_slist_remove_link (e->cursor_position_stack, e->cursor_position_stack);
+ link = e->cursor_position_stack;
+ e->cursor_position_stack = g_slist_remove_link (e->cursor_position_stack, link);
+ g_slist_free (link);
html_engine_show_cursor (e);
}
Index: src/htmlinterval.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmlinterval.c,v
retrieving revision 1.20
diff -u -p -r1.20 htmlinterval.c
--- src/htmlinterval.c 15 Oct 2003 14:42:23 -0000 1.20
+++ src/htmlinterval.c 11 Apr 2005 12:39:12 -0000
@@ -218,12 +218,19 @@ get_downtree_line (HTMLObject *o)
static HTMLEngine *
do_downtree_lines_intersection (GSList **l1, GSList **l2, HTMLEngine *e)
{
+ GSList *link;
+
g_assert ((*l1)->data == (*l2)->data);
while (*l1 && *l2 && (*l1)->data == (*l2)->data) {
e = html_object_get_engine (HTML_OBJECT ((*l1)->data), e);
- *l1 = g_slist_remove_link (*l1, *l1);
- *l2 = g_slist_remove_link (*l2, *l2);
+ link = *l1;
+ *l1 = g_slist_remove_link (*l1, link);
+ g_slist_free (link);
+
+ link = *l2;
+ *l2 = g_slist_remove_link (*l2, link);
+ g_slist_free (link);
}
return e;
Index: src/htmltext.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmltext.c,v
retrieving revision 1.279
diff -u -p -r1.279 htmltext.c
--- src/htmltext.c 23 Mar 2005 12:35:57 -0000 1.279
+++ src/htmltext.c 11 Apr 2005 12:39:19 -0000
@@ -898,6 +898,8 @@ html_text_get_attr_list_list (PangoAttrL
g_slist_free (l);
}
} while (pango_attr_iterator_next (iter));
+
+ pango_attr_iterator_destroy (iter);
}
}
@@ -1800,6 +1802,8 @@ save (HTMLObject *self, HTMLEngineSaveSt
html_text_free_attrs (attrs);
}
} while (pango_attr_iterator_next (iter));
+
+ pango_attr_iterator_destroy (iter);
g_slist_free (links);
}
@@ -2108,7 +2112,10 @@ static GList *
remove_one (GList *list, GList *link)
{
spell_error_destroy ((SpellError *) link->data);
- return g_list_remove_link (list, link);
+ list = g_list_remove_link (list, link);
+ g_list_free (link);
+
+ return list;
}
static GList *
Index: src/htmltextslave.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmltextslave.c,v
retrieving revision 1.191
diff -u -p -r1.191 htmltextslave.c
--- src/htmltextslave.c 23 Mar 2005 12:35:57 -0000 1.191
+++ src/htmltextslave.c 11 Apr 2005 12:39:23 -0000
@@ -174,22 +174,24 @@ glyphs_destroy (GList *glyphs)
}
inline static void
-glyph_items_destroy (GList *glyph_items)
+glyph_items_destroy (GSList *glyph_items)
{
- GList *l;
+ GSList *l;
- for (l = glyph_items; l; l = l->next->next) {
- HTMLTextSlaveGlyphItem *gi = (HTMLTextSlaveGlyphItem *) gi;
+ for (l = glyph_items; l; l = l->next) {
+ HTMLTextSlaveGlyphItem *gi = (HTMLTextSlaveGlyphItem *) l->data;
if (gi->type == HTML_TEXT_SLAVE_GLYPH_ITEM_CREATED) {
- pango_item_free (gi->glyph_item.item);
- pango_glyph_string_free (gi->glyph_item.glyphs);
+ if (gi->glyph_item.item)
+ pango_item_free (gi->glyph_item.item);
+ if (gi->glyph_item.glyphs)
+ pango_glyph_string_free (gi->glyph_item.glyphs);
g_free (gi->widths);
}
g_free (gi);
}
- g_list_free (glyph_items);
+ g_slist_free (glyph_items);
}
static gboolean
@@ -644,8 +646,13 @@ get_glyph_items_in_range (HTMLTextSlave
offset += item->num_chars;
}
- if (glyph_items)
- glyph_items = reorder_glyph_items (g_slist_reverse (glyph_items), n_items);
+ if (glyph_items) {
+ GSList *reversed;
+
+ reversed = g_slist_reverse (glyph_items);
+ glyph_items = reorder_glyph_items (reversed, n_items);
+ g_slist_free (reversed);
+ }
return glyph_items;
}
@@ -1058,8 +1065,8 @@ static void
clear_glyph_items (HTMLTextSlave *slave)
{
if (slave->glyph_items) {
- glyph_items_destroy (slave->glyphs);
- slave->glyphs = NULL;
+ glyph_items_destroy (slave->glyph_items);
+ slave->glyph_items = NULL;
}
}
@@ -1069,6 +1076,7 @@ destroy (HTMLObject *obj)
HTMLTextSlave *slave = HTML_TEXT_SLAVE (obj);
clear_glyphs (slave);
+ clear_glyph_items (slave);
HTML_OBJECT_CLASS (parent_class)->destroy (obj);
}
Index: src/htmlundo.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmlundo.c,v
retrieving revision 1.18
diff -u -p -r1.18 htmlundo.c
--- src/htmlundo.c 16 Sep 2004 10:10:53 -0000 1.18
+++ src/htmlundo.c 11 Apr 2005 12:39:24 -0000
@@ -54,6 +54,7 @@ static void html_undo_debug (HTMLUndo *u
#endif
static void add_used_and_redo_to_undo (HTMLUndo *undo);
+static void level_destroy (HTMLUndoData *data);
inline static void
stack_copy (HTMLUndoStack *src, HTMLUndoStack *dst)
@@ -75,7 +76,16 @@ destroy_action_list (GList *lp)
GList *p;
for (p = lp; p != NULL; p = p->next)
- html_undo_action_destroy ((HTMLUndoAction *) p->data);
+ html_undo_action_destroy (HTML_UNDO_ACTION (p->data));
+}
+
+static void
+destroy_levels_list (GSList *lp)
+{
+ GSList *p;
+
+ for (p = lp; p != NULL; p = p->next)
+ level_destroy (p->data);
}
@@ -98,6 +108,16 @@ html_undo_destroy (HTMLUndo *undo)
destroy_action_list (undo->undo_used.stack);
destroy_action_list (undo->redo.stack);
+ g_list_free (undo->undo.stack);
+ g_list_free (undo->undo_used.stack);
+ g_list_free (undo->redo.stack);
+
+ destroy_levels_list (undo->undo_levels);
+ destroy_levels_list (undo->redo_levels);
+
+ g_slist_free (undo->undo_levels);
+ g_slist_free (undo->redo_levels);
+
g_free (undo);
}
@@ -347,8 +367,8 @@ level_destroy (HTMLUndoData *data)
level = HTML_UNDO_LEVEL (data);
- for (; level->stack.stack; level->stack.stack = level->stack.stack->next)
- html_undo_action_destroy (HTML_UNDO_ACTION (level->stack.stack->data));
+ destroy_action_list (level->stack.stack);
+ g_list_free (level->stack.stack);
g_free (level->description [HTML_UNDO_UNDO]);
g_free (level->description [HTML_UNDO_REDO]);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]