Commit 8a9b6d52 authored by Morten Welinder's avatar Morten Welinder

Borders: new leak printer at leak.

parent 2f472332
2014-03-15 Morten Welinder <terra@gnome.org>
* src/style-border.c (gnm_border_shutdown): New function to help
debug leaks.
2014-03-15 Jean Brefort <jean.brefort@normalesup.org>
* src/item-grid.c (item_grid_realize), (cb_cursor_come_to_rest): move
......
......@@ -40,6 +40,7 @@
#include "print-info.h"
#include "style-font.h"
#include "mstyle.h"
#include "style-border.h"
#include "style-color.h"
#include "print.h"
#include "dependent.h"
......@@ -320,6 +321,7 @@ gnm_shutdown (void)
value_shutdown ();
gnm_font_shutdown ();
gnm_border_shutdown ();
gnm_color_shutdown ();
gnm_conf_shutdown ();
gnm_style_shutdown ();
......
......@@ -29,6 +29,7 @@
#include "sheet-style.h"
#include "sheet.h"
#include <gdk/gdk.h>
#include <string.h>
struct LineDotPattern {
const gint elements;
......@@ -211,6 +212,7 @@ gnm_style_border_fetch (GnmStyleBorderType line_type,
}
g_return_val_if_fail (color != NULL, NULL);
memset (&key, 0, sizeof (key));
key.line_type = line_type;
key.color = color;
......@@ -225,9 +227,7 @@ gnm_style_border_fetch (GnmStyleBorderType line_type,
border_hash = g_hash_table_new (style_border_hash,
style_border_equal);
border = g_new0 (GnmBorder, 1);
*border = key;
g_hash_table_insert (border_hash, border, border);
border = g_memdup (&key, sizeof (key));
border->ref_count = 1;
border->width = gnm_style_border_get_width (line_type);
if (border->line_type == GNM_STYLE_BORDER_DOUBLE) {
......@@ -237,6 +237,7 @@ gnm_style_border_fetch (GnmStyleBorderType line_type,
border->begin_margin = (border->width) > 1 ? 1 : 0;
border->end_margin = (border->width) > 2 ? 1 : 0;
}
g_hash_table_insert (border_hash, border, border);
return border;
}
......@@ -316,6 +317,27 @@ gnm_style_border_unref (GnmBorder *border)
g_free (border);
}
static void
cb_border_leak (gpointer key, gpointer value, gpointer user_data)
{
GnmBorder *border = value;
g_printerr ("Leaking style-border at %p [color=%p line=%d].\n",
(void *)border,
border->color,
border->line_type);
}
void
gnm_border_shutdown (void)
{
if (border_hash) {
g_hash_table_foreach (border_hash, cb_border_leak, NULL);
g_hash_table_destroy (border_hash);
border_hash = NULL;
}
}
GType
gnm_border_get_type (void)
{
......
......@@ -64,6 +64,7 @@ struct _GnmBorder {
gint ref_count;
};
void gnm_border_shutdown (void);
GType gnm_border_get_type (void);
void gnm_style_border_unref (GnmBorder *border);
GnmBorder *gnm_style_border_ref (GnmBorder *border);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment