Index: glib/poppler-document.cc =================================================================== RCS file: /cvs/poppler/poppler/glib/poppler-document.cc,v retrieving revision 1.45 diff -u -p -r1.45 poppler-document.cc --- glib/poppler-document.cc 4 Jul 2007 08:26:52 -0000 1.45 +++ glib/poppler-document.cc 8 Jul 2007 01:37:20 -0000 @@ -1188,6 +1188,42 @@ poppler_fonts_iter_new (GooList *items) return iter; } + +typedef struct _PopplerFontInfoClass PopplerFontInfoClass; +struct _PopplerFontInfoClass +{ + GObjectClass parent_class; +}; + +G_DEFINE_TYPE (PopplerFontInfo, poppler_font_info, G_TYPE_OBJECT); + +static void poppler_font_info_finalize (GObject *object); + + +static void +poppler_font_info_class_init (PopplerFontInfoClass *klass) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + + gobject_class->finalize = poppler_font_info_finalize; +} + +static void +poppler_font_info_init (PopplerFontInfo *font_info) +{ + font_info->document = NULL; + font_info->scanner = NULL; +} + +static void +poppler_font_info_finalize (GObject *object) +{ + PopplerFontInfo *font_info = POPPLER_FONT_INFO (object); + + delete font_info->scanner; + g_object_unref (font_info->document); +} + PopplerFontInfo * poppler_font_info_new (PopplerDocument *document) { @@ -1195,7 +1231,8 @@ poppler_font_info_new (PopplerDocument * g_return_val_if_fail (POPPLER_IS_DOCUMENT (document), NULL); - font_info = g_new0 (PopplerFontInfo, 1); + font_info = (PopplerFontInfo *) g_object_new (POPPLER_TYPE_FONT_INFO, + NULL); font_info->document = (PopplerDocument *) g_object_ref (document); font_info->scanner = new FontInfoScanner(document->doc); @@ -1225,14 +1262,13 @@ poppler_font_info_scan (PopplerFontInfo return (items != NULL); } +/* For backward compatibility */ void poppler_font_info_free (PopplerFontInfo *font_info) { g_return_if_fail (font_info != NULL); - delete font_info->scanner; - g_object_unref (font_info->document); - g_free (font_info); + g_object_unref (font_info); } Index: glib/poppler-document.h =================================================================== RCS file: /cvs/poppler/poppler/glib/poppler-document.h,v retrieving revision 1.25 diff -u -p -r1.25 poppler-document.h --- glib/poppler-document.h 30 Jun 2007 08:25:16 -0000 1.25 +++ glib/poppler-document.h 8 Jul 2007 01:37:20 -0000 @@ -133,11 +133,15 @@ PopplerAction *poppler_index_iter_get gboolean poppler_index_iter_next (PopplerIndexIter *iter); /* Interface for getting the Fonts of a poppler_document */ +#define POPPLER_TYPE_FONT_INFO (poppler_font_info_get_type ()) +#define POPPLER_FONT_INFO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), POPPLER_TYPE_FONT_INFO, PopplerFontInfo)) +#define POPPLER_IS_FONT_INFO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), POPPLER_TYPE_FONT_INFO)) +GType poppler_font_info_get_type (void) G_GNUC_CONST; PopplerFontInfo *poppler_font_info_new (PopplerDocument *document); gboolean poppler_font_info_scan (PopplerFontInfo *font_info, int n_pages, PopplerFontsIter **iter); -void poppler_font_info_free (PopplerFontInfo *font_info); +void poppler_font_info_free (PopplerFontInfo *font_info); #define POPPLER_TYPE_FONTS_ITER (poppler_fonts_iter_get_type ()) GType poppler_fonts_iter_get_type (void) G_GNUC_CONST; Index: glib/poppler-private.h =================================================================== RCS file: /cvs/poppler/poppler/glib/poppler-private.h,v retrieving revision 1.20 diff -u -p -r1.20 poppler-private.h --- glib/poppler-private.h 4 Jul 2007 08:26:52 -0000 1.20 +++ glib/poppler-private.h 8 Jul 2007 01:37:20 -0000 @@ -45,6 +45,7 @@ struct _PopplerPSFile struct _PopplerFontInfo { + GObject parent_instance; PopplerDocument *document; FontInfoScanner *scanner; }; Index: glib/test-poppler-glib.c =================================================================== RCS file: /cvs/poppler/poppler/glib/test-poppler-glib.c,v retrieving revision 1.30 diff -u -p -r1.30 test-poppler-glib.c --- glib/test-poppler-glib.c 7 Jul 2007 16:23:56 -0000 1.30 +++ glib/test-poppler-glib.c 8 Jul 2007 01:37:20 -0000 @@ -112,7 +112,7 @@ print_document_info (PopplerDocument *do poppler_fonts_iter_free (fonts_iter); } } - poppler_font_info_free (font_info); + g_object_unref (font_info); index_iter = poppler_index_iter_new (document); if (index_iter)