[gtk+] textlayout: cleanup
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] textlayout: cleanup
- Date: Sun, 18 Dec 2011 17:46:32 +0000 (UTC)
commit 69fba5d3ed546cc7e6743c4e54af02ea384d05a4
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Sun Dec 18 18:45:49 2011 +0100
textlayout: cleanup
Use g_clear_object, move unrefs to dispose and reorganize code
gtk/gtktextlayout.c | 96 +++++++++++++++++++++++++--------------------------
1 files changed, 47 insertions(+), 49 deletions(-)
---
diff --git a/gtk/gtktextlayout.c b/gtk/gtktextlayout.c
index 572fb15..d3baf19 100644
--- a/gtk/gtktextlayout.c
+++ b/gtk/gtktextlayout.c
@@ -170,8 +170,6 @@ enum {
#define PIXEL_BOUND(d) (((d) + PANGO_SCALE - 1) / PANGO_SCALE)
-static void gtk_text_layout_finalize (GObject *object);
-
static guint signals[LAST_SIGNAL] = { 0 };
PangoAttrType gtk_text_attr_appearance_type = 0;
@@ -179,10 +177,57 @@ PangoAttrType gtk_text_attr_appearance_type = 0;
G_DEFINE_TYPE (GtkTextLayout, gtk_text_layout, G_TYPE_OBJECT)
static void
+gtk_text_layout_dispose (GObject *object)
+{
+ GtkTextLayout *layout;
+
+ layout = GTK_TEXT_LAYOUT (object);
+
+ gtk_text_layout_set_buffer (layout, NULL);
+
+ if (layout->default_style != NULL)
+ {
+ gtk_text_attributes_unref (layout->default_style);
+ layout->default_style = NULL;
+ }
+
+ g_clear_object (&layout->ltr_context);
+ g_clear_object (&layout->rtl_context);
+
+ if (layout->one_display_cache)
+ {
+ GtkTextLineDisplay *tmp_display = layout->one_display_cache;
+ layout->one_display_cache = NULL;
+ gtk_text_layout_free_line_display (layout, tmp_display);
+ }
+
+ if (layout->preedit_attrs != NULL)
+ {
+ pango_attr_list_unref (layout->preedit_attrs);
+ layout->preedit_attrs = NULL;
+ }
+
+ G_OBJECT_CLASS (gtk_text_layout_parent_class)->dispose (object);
+}
+
+static void
+gtk_text_layout_finalize (GObject *object)
+{
+ GtkTextLayout *layout;
+
+ layout = GTK_TEXT_LAYOUT (object);
+
+ g_free (layout->preedit_string);
+
+ G_OBJECT_CLASS (gtk_text_layout_parent_class)->finalize (object);
+}
+
+static void
gtk_text_layout_class_init (GtkTextLayoutClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ object_class->dispose = gtk_text_layout_dispose;
object_class->finalize = gtk_text_layout_finalize;
klass->wrap = gtk_text_layout_real_wrap;
@@ -251,53 +296,6 @@ free_style_cache (GtkTextLayout *text_layout)
}
}
-static void
-gtk_text_layout_finalize (GObject *object)
-{
- GtkTextLayout *layout;
-
- layout = GTK_TEXT_LAYOUT (object);
-
- gtk_text_layout_set_buffer (layout, NULL);
-
- if (layout->default_style)
- gtk_text_attributes_unref (layout->default_style);
- layout->default_style = NULL;
-
- if (layout->ltr_context)
- {
- g_object_unref (layout->ltr_context);
- layout->ltr_context = NULL;
- }
- if (layout->rtl_context)
- {
- g_object_unref (layout->rtl_context);
- layout->rtl_context = NULL;
- }
-
- if (layout->one_display_cache)
- {
- GtkTextLineDisplay *tmp_display = layout->one_display_cache;
- layout->one_display_cache = NULL;
- gtk_text_layout_free_line_display (layout, tmp_display);
- }
-
- if (layout->preedit_string)
- {
- g_free (layout->preedit_string);
- layout->preedit_string = NULL;
- }
-
- if (layout->preedit_attrs)
- {
- pango_attr_list_unref (layout->preedit_attrs);
- layout->preedit_attrs = NULL;
- }
-
-
- G_OBJECT_CLASS (gtk_text_layout_parent_class)->finalize (object);
-}
-
/**
* gtk_text_layout_set_buffer:
* @buffer: (allow-none):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]