[evolution-patches] gtkhtml leaks are green
- From: Larry Ewing <lewing ximian com>
- To: patches <evolution-patches ximian com>, Radek Doulik <rodo ximian com>
- Subject: [evolution-patches] gtkhtml leaks are green
- Date: 24 Jun 2003 18:00:02 -0500
This fixes a whole bunch of tiny leaks in gtkhtml. I have some
additional changes for htmlimage but I need to extract them from som
animation fixes I was working on
--Larry
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/ChangeLog,v
retrieving revision 1.1811
diff -u -p -r1.1811 ChangeLog
--- ChangeLog 13 Jun 2003 21:42:59 -0000 1.1811
+++ ChangeLog 24 Jun 2003 22:50:26 -0000
@@ -1,3 +1,28 @@
+2003-06-24 Larry Ewing <lewing ximian com>
+
+ * htmlengine.c (parse_body): add helper functions to push/pop clue
+ levels.
+ (html_engine_finalize): unref the body background. If the body
+ stack isn't empty clear it.
+
+2003-06-20 Larry Ewing <lewing ximian com>
+
+ * gtkhtml.c (gtk_html_editor_event_command): unset the args.
+ (gtk_html_editor_event): unset and free the return value.
+
+ * htmlfontmanager.c: fix ref font refcounting problems.
+
+ * htmlgdkpainter.c (unref_font): free the font description.
+
+ * htmlmap.c (html_map_destroy): free the map structure as well.
+
+ * htmlpainter.c (finalize): free the font_face.
+
+ * htmlstyle.c (html_style_add_attribute): keep the correct ref
+ count on the color.
+
+ * htmltable.c (divide_into_percented_all): don't leak active.
+
2003-06-13 Larry Ewing <lewing ximian com>
* htmlengine.c (html_engine_finalize): clear some of the various
Index: gtkhtml.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/gtkhtml.c,v
retrieving revision 1.516
diff -u -p -r1.516 gtkhtml.c
--- gtkhtml.c 13 Jun 2003 21:42:59 -0000 1.516
+++ gtkhtml.c 24 Jun 2003 22:50:27 -0000
@@ -4813,18 +4813,27 @@ gtk_html_editor_event_command (GtkHTML *
memset (&arg, 0, sizeof (GValue));
g_value_init (&arg, G_TYPE_STRING);
- g_value_set_static_string (&arg, get_value_nick (com_type));
+ g_value_set_string (&arg, get_value_nick (com_type));
/* printf ("sending %s\n", GTK_VALUE_STRING (*args [0])); */
gtk_html_editor_event (html, before ? GTK_HTML_EDITOR_EVENT_COMMAND_BEFORE : GTK_HTML_EDITOR_EVENT_COMMAND_AFTER,
&arg);
+
+ g_value_unset (&arg);
}
void
gtk_html_editor_event (GtkHTML *html, GtkHTMLEditorEventType event, GValue *args)
{
+ GValue *retval;
+
if (html->editor_api && !html->engine->block_events)
- (*html->editor_api->event) (html, event, args, html->editor_data);
+ retval = (*html->editor_api->event) (html, event, args, html->editor_data);
+
+ if (retval) {
+ g_value_unset (retval);
+ g_free (retval);
+ }
}
gboolean
Index: htmlengine.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmlengine.c,v
retrieving revision 1.544
diff -u -p -r1.544 htmlengine.c
--- htmlengine.c 13 Jun 2003 21:42:59 -0000 1.544
+++ htmlengine.c 24 Jun 2003 22:50:28 -0000
@@ -144,7 +144,7 @@ static void update_embedded
static void html_engine_map_table_clear (HTMLEngine *e);
static void html_engine_id_table_clear (HTMLEngine *e);
-static void html_engine_add_map (HTMLEngine *e, HTMLMap *map);
+static void html_engine_add_map (HTMLEngine *e, const char *);
static void clear_pending_expose (HTMLEngine *e);
static GtkLayoutClass *parent_class = NULL;
@@ -817,6 +817,32 @@ block_end_div (HTMLEngine *e, HTMLObject
}
+static void
+push_level (HTMLEngine *e)
+{
+ html_stack_push (e->body_stack, e->span_stack);
+ html_stack_push (e->body_stack, e->clueflow_style_stack);
+
+ e->span_stack = html_stack_new (free_element);
+ e->clueflow_style_stack = html_stack_new (NULL);
+
+ html_stack_push (e->body_stack, GINT_TO_POINTER (e->pending_para));
+ html_stack_push (e->body_stack, GINT_TO_POINTER (e->avoid_para));
+}
+
+static void
+pop_level (HTMLEngine *e)
+{
+ e->avoid_para = GPOINTER_TO_INT (html_stack_pop (e->body_stack));
+ e->pending_para = GPOINTER_TO_INT (html_stack_pop (e->body_stack));
+
+ html_stack_destroy (e->clueflow_style_stack);
+ html_stack_destroy (e->span_stack);
+
+ e->clueflow_style_stack = html_stack_pop (e->body_stack);
+ e->span_stack = html_stack_pop (e->body_stack);
+}
+
static gchar *
parse_body (HTMLEngine *e, HTMLObject *clue, const gchar *end[], gboolean toplevel, gboolean begin)
{
@@ -825,15 +851,7 @@ parse_body (HTMLEngine *e, HTMLObject *c
gboolean final = FALSE;
if (begin && !toplevel) {
- html_stack_push (e->body_stack, e->span_stack);
- html_stack_push (e->body_stack, e->clueflow_style_stack);
-
- e->span_stack = html_stack_new (free_element);
- e->clueflow_style_stack = html_stack_new (NULL);
-
- html_stack_push (e->body_stack, GINT_TO_POINTER (e->pending_para));
- html_stack_push (e->body_stack, GINT_TO_POINTER (e->avoid_para));
-
+ push_level (e);
push_block (e, ID_BODY, 4, NULL, 0, 0);
}
@@ -895,15 +913,7 @@ parse_body (HTMLEngine *e, HTMLObject *c
if (!toplevel) {
pop_block (e, ID_BODY, clue);
-
- e->avoid_para = GPOINTER_TO_INT (html_stack_pop (e->body_stack));
- e->pending_para = GPOINTER_TO_INT (html_stack_pop (e->body_stack));
-
- html_stack_destroy (e->clueflow_style_stack);
- html_stack_destroy (e->span_stack);
-
- e->clueflow_style_stack = html_stack_pop (e->body_stack);
- e->span_stack = html_stack_pop (e->body_stack);
+ pop_level (e);
}
}
@@ -2752,12 +2762,7 @@ parse_m (HTMLEngine *e, HTMLObject *_clu
if (strncasecmp (token, "name=", 5) == 0) {
const char *name = token + 5;
- e->map = HTML_MAP (html_map_new (name));
-
- if (e->map == NULL)
- return;
-
- html_engine_add_map (e, e->map);
+ html_engine_add_map (e, name);
}
}
} else if (strncmp (str, "/map", 4) == 0) {
@@ -3272,6 +3277,7 @@ html_engine_finalize (GObject *object)
gtk_timeout_remove (engine->redraw_idle_id);
engine->redraw_idle_id = 0;
}
+
/* remove all the timers associated with image pointers also */
if (engine->image_factory) {
html_image_factory_stop_animations (engine->image_factory);
@@ -3338,6 +3344,11 @@ html_engine_finalize (GObject *object)
html_object_destroy (clue);
}
+ if (engine->bgPixmapPtr) {
+ html_image_factory_unregister (engine->image_factory, engine->bgPixmapPtr, NULL);
+ engine->bgPixmapPtr = NULL;
+ }
+
if (engine->image_factory) {
html_image_factory_free (engine->image_factory);
engine->image_factory = NULL;
@@ -3348,6 +3359,14 @@ html_engine_finalize (GObject *object)
engine->painter = NULL;
}
+ if (engine->body_stack) {
+ while (!html_stack_is_empty (engine->body_stack))
+ pop_level (engine);
+
+ html_stack_destroy (engine->body_stack);
+ engine->body_stack = NULL;
+ }
+
if (engine->span_stack) {
html_stack_destroy (engine->span_stack);
engine->span_stack = NULL;
@@ -3373,11 +3392,6 @@ html_engine_finalize (GObject *object)
engine->embeddedStack = NULL;
}
- if (engine->body_stack) {
- html_stack_destroy (engine->body_stack);
- engine->body_stack = NULL;
- }
-
if (engine->tempStrings) {
for (p = engine->tempStrings; p != NULL; p = p->next)
g_free (p->data);
@@ -5766,15 +5780,20 @@ html_engine_saved (HTMLEngine *e)
}
static void
-html_engine_add_map (HTMLEngine *e, HTMLMap *map)
+html_engine_add_map (HTMLEngine *e, const char *name)
{
gpointer old_key = NULL, old_val;
-
- if (!e->map_table)
+
+ if (!e->map_table) {
e->map_table = g_hash_table_new (g_str_hash, g_str_equal);
- else if (!g_hash_table_lookup_extended (e->map_table, map->name, &old_key, &old_val))
- old_key = NULL;
- g_hash_table_insert (e->map_table, map->name, map);
+ }
+
+ /* only add a new map if the name is unique */
+ if (!g_hash_table_lookup_extended (e->map_table, name, &old_key, &old_val)) {
+ HTMLMap *map = html_map_new (name);
+
+ g_hash_table_insert (e->map_table, map->name, map);
+ }
}
static gboolean
Index: htmlfontmanager.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmlfontmanager.c,v
retrieving revision 1.39
diff -u -p -r1.39 htmlfontmanager.c
--- htmlfontmanager.c 15 May 2003 20:26:35 -0000 1.39
+++ htmlfontmanager.c 24 Jun 2003 22:50:28 -0000
@@ -65,7 +65,7 @@ html_font_set_release (HTMLFontSet *set,
for (i=0; i<GTK_HTML_FONT_STYLE_MAX_FONT; i++) {
if (set->font [i])
- html_painter_unref_font (painter, set->font [i]);
+ html_font_unref (set->font [i], painter);
set->font [i] = NULL;
}
}
@@ -224,7 +224,7 @@ html_font_set_font (HTMLFontManager *man
/* set font in font set */
idx = html_font_set_get_idx (style);
if (set->font [idx] && font != set->font [idx])
- html_painter_unref_font (manager->painter, set->font [idx]);
+ html_font_unref (set->font [idx], manager->painter);
set->font [idx] = font;
}
@@ -353,7 +353,6 @@ html_font_manager_get_font (HTMLFontMana
} else {
/* some unavailable non-default font => use default one */
font = html_font_manager_get_font (manager, NULL, style);
- html_font_ref (font, manager->painter);
}
if (font)
html_font_set_font (manager, set, style, font);
@@ -400,8 +399,9 @@ html_font_ref (HTMLFont *font, HTMLPaint
void
html_font_unref (HTMLFont *font, HTMLPainter *painter)
{
- html_painter_unref_font (painter, font);
font->ref_count --;
- if (font->ref_count <= 0)
+ html_painter_unref_font (painter, font);
+
+ if (font->ref_count < 1)
html_font_destroy (font);
}
Index: htmlgdkpainter.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmlgdkpainter.c,v
retrieving revision 1.120
diff -u -p -r1.120 htmlgdkpainter.c
--- htmlgdkpainter.c 9 Apr 2003 04:03:51 -0000 1.120
+++ htmlgdkpainter.c 24 Jun 2003 22:50:28 -0000
@@ -241,7 +241,10 @@ ref_font (HTMLPainter *painter, HTMLFont
static void
unref_font (HTMLPainter *painter, HTMLFont *font)
{
- /* FIX2 stop leaking font description */
+ if (font->ref_count < 1) {
+ pango_font_description_free (font->data);
+ font->data = NULL;
+ }
}
Index: htmlmap.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmlmap.c,v
retrieving revision 1.2
diff -u -p -r1.2 htmlmap.c
--- htmlmap.c 29 Jul 2002 19:18:19 -0000 1.2
+++ htmlmap.c 24 Jun 2003 22:50:28 -0000
@@ -38,6 +38,7 @@ html_map_destroy (HTMLMap *map)
map->shapes = NULL;
g_free (map->name);
+ g_free (map);
}
void
Index: htmlpainter.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmlpainter.c,v
retrieving revision 1.90
diff -u -p -r1.90 htmlpainter.c
--- htmlpainter.c 19 Mar 2003 04:09:50 -0000 1.90
+++ htmlpainter.c 24 Jun 2003 22:50:28 -0000
@@ -53,6 +53,7 @@ finalize (GObject *object)
html_font_manager_finalize (&painter->font_manager);
html_colorset_destroy (painter->color_set);
+ g_free (painter->font_face);
/* FIXME ownership of the color set? */
Index: htmlstyle.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmlstyle.c,v
retrieving revision 1.5
diff -u -p -r1.5 htmlstyle.c
--- htmlstyle.c 16 Apr 2003 17:51:55 -0000 1.5
+++ htmlstyle.c 24 Jun 2003 22:50:28 -0000
@@ -216,7 +216,9 @@ html_style_add_attribute (HTMLStyle *sty
GdkColor color;
if (parse_color (g_strstrip (text + 7), &color)) {
- html_style_add_color (style, html_color_new_from_gdk_color (&color));
+ HTMLColor *hc = html_color_new_from_gdk_color (&color);
+ html_style_add_color (style, hc);
+ html_color_unref (hc);
}
} else if (!strncasecmp ("text-decoration: none", text, 21)) {
html_style_unset_decoration (style, ~GTK_HTML_FONT_STYLE_SIZE_MASK);
Index: htmltable.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmltable.c,v
retrieving revision 1.168
diff -u -p -r1.168 htmltable.c
--- htmltable.c 13 Jun 2003 21:42:59 -0000 1.168
+++ htmltable.c 24 Jun 2003 22:50:29 -0000
@@ -1662,6 +1662,8 @@ divide_into_percented_all (HTMLTable *ta
for (c = 0; c < table->totalCols; c++)
if (active [c] && max_size [c] < ((gdouble) width * PERC (c)) / percent)
max_size [c] = ((gdouble) width) * (PERC (c)) / percent;
+
+ g_free (active);
}
#define CSPAN (MIN (cell->col + cell->cspan, table->totalCols) - cell->col - 1)
Index: testgtkhtml.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/testgtkhtml.c,v
retrieving revision 1.114
diff -u -p -r1.114 testgtkhtml.c
--- testgtkhtml.c 19 May 2003 12:32:26 -0000 1.114
+++ testgtkhtml.c 24 Jun 2003 22:50:29 -0000
@@ -656,6 +656,7 @@ url_requested (GtkHTML *html, const char
SoupContext *ctx;
SoupMessage *msg;
+ g_warning ("full_url=$s", full_url);
ctx = soup_context_get (full_url);
msg = soup_message_new (ctx, SOUP_METHOD_GET);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]