[gnumeric] COmpilation: use g_clear_object more.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] COmpilation: use g_clear_object more.
- Date: Tue, 26 Mar 2013 02:47:33 +0000 (UTC)
commit 85cc3229182d361f8ffbe8995c8a6836c37d657f
Author: Morten Welinder <terra gnome org>
Date: Mon Mar 25 22:47:15 2013 -0400
COmpilation: use g_clear_object more.
src/gnm-pane.c | 27 ++++++----------------
src/gnm-so-filled.c | 5 ++-
src/gnm-so-line.c | 3 +-
src/mstyle.c | 10 +------
src/sheet-control-gui.c | 10 +------
src/wbc-gtk.c | 56 +++++++++++++++++++++-------------------------
src/widgets/gnm-dao.c | 5 +---
7 files changed, 42 insertions(+), 74 deletions(-)
---
diff --git a/src/gnm-pane.c b/src/gnm-pane.c
index 56c05b3..a3aeb0a 100644
--- a/src/gnm-pane.c
+++ b/src/gnm-pane.c
@@ -874,10 +874,7 @@ gnm_pane_dispose (GObject *obj)
g_slist_free_full (pane->cursor.expr_range, g_object_unref);
pane->cursor.expr_range = NULL;
- if (pane->mouse_cursor) {
- g_object_unref (pane->mouse_cursor);
- pane->mouse_cursor = NULL;
- }
+ g_clear_object (&pane->mouse_cursor);
gnm_pane_clear_obj_size_tip (pane);
if (pane->drag.ctrl_pts) {
@@ -2092,14 +2089,8 @@ gnm_pane_size_guide_stop (GnmPane *pane)
{
g_return_if_fail (pane != NULL);
- if (pane->size_guide.start != NULL) {
- g_object_unref (pane->size_guide.start);
- pane->size_guide.start = NULL;
- }
- if (pane->size_guide.guide != NULL) {
- g_object_unref (pane->size_guide.guide);
- pane->size_guide.guide = NULL;
- }
+ g_clear_object (&pane->size_guide.start);
+ g_clear_object (&pane->size_guide.guide);
}
/**
@@ -2197,8 +2188,8 @@ void
gnm_pane_rangesel_stop (GnmPane *pane)
{
g_return_if_fail (pane->cursor.rangesel != NULL);
- g_object_unref (pane->cursor.rangesel);
- pane->cursor.rangesel = NULL;
+
+ g_clear_object (&pane->cursor.rangesel);
/* Make the primary cursor visible again */
gnm_item_cursor_set_visibility (pane->cursor.std, TRUE);
@@ -2236,8 +2227,7 @@ gnm_pane_special_cursor_stop (GnmPane *pane)
{
g_return_if_fail (pane->cursor.special != NULL);
- g_object_unref (pane->cursor.special);
- pane->cursor.special = NULL;
+ g_clear_object (&pane->cursor.special);
}
void
@@ -2298,10 +2288,7 @@ gnm_pane_edit_start (GnmPane *pane)
void
gnm_pane_edit_stop (GnmPane *pane)
{
- if (pane->editor != NULL) {
- g_object_unref (pane->editor);
- pane->editor = NULL;
- }
+ g_clear_object (&pane->editor);
}
void
diff --git a/src/gnm-so-filled.c b/src/gnm-so-filled.c
index 43d18c8..577d279 100644
--- a/src/gnm-so-filled.c
+++ b/src/gnm-so-filled.c
@@ -482,10 +482,11 @@ gnm_so_filled_finalize (GObject *object)
{
GnmSOFilled *sof = GNM_SO_FILLED (object);
- g_object_unref (sof->style);
- sof->style = NULL;
+ g_clear_object (&sof->style);
+
g_free (sof->text);
sof->text = NULL;
+
if (NULL != sof->markup) {
pango_attr_list_unref (sof->markup);
sof->markup = NULL;
diff --git a/src/gnm-so-line.c b/src/gnm-so-line.c
index 2961cfc..5d95303 100644
--- a/src/gnm-so-line.c
+++ b/src/gnm-so-line.c
@@ -441,8 +441,7 @@ static void
gnm_so_line_finalize (GObject *object)
{
GnmSOLine *sol = GNM_SO_LINE (object);
- g_object_unref (sol->style);
- sol->style = NULL;
+ g_clear_object (&sol->style);
G_OBJECT_CLASS (gnm_so_line_parent_class)->finalize (object);
}
diff --git a/src/mstyle.c b/src/mstyle.c
index d7e1807..a17d38b 100644
--- a/src/mstyle.c
+++ b/src/mstyle.c
@@ -549,14 +549,8 @@ gnm_style_clear_pango (GnmStyle *style)
static inline void
gnm_style_clear_font (GnmStyle *style)
{
- if (style->font) {
- gnm_font_unref (style->font);
- style->font = NULL;
- }
- if (style->font_context) {
- g_object_unref (style->font_context);
- style->font_context = NULL;
- }
+ g_clear_object (&style->font);
+ g_clear_object (&style->font_context);
}
/**
diff --git a/src/sheet-control-gui.c b/src/sheet-control-gui.c
index bd6fa24..abdce6d 100644
--- a/src/sheet-control-gui.c
+++ b/src/sheet-control-gui.c
@@ -687,10 +687,7 @@ cb_table_destroy (SheetControlGUI *scg)
SheetControl *sc = (SheetControl *) scg;
int i;
- if (scg->grid) {
- g_object_unref (scg->grid);
- scg->grid = NULL;
- }
+ g_clear_object (&scg->grid);
scg_mode_edit (scg); /* finish any object edits */
scg_unant (sc); /* Make sure that everything is unanted */
@@ -1782,10 +1779,7 @@ scg_finalize (GObject *object)
scg->grid = NULL;
}
- if (scg->label) {
- g_object_unref (scg->label);
- scg->label = NULL;
- }
+ g_clear_object (&scg->label);
if (scg->wbcg != NULL)
g_object_weak_unref (G_OBJECT (scg->wbcg),
diff --git a/src/wbc-gtk.c b/src/wbc-gtk.c
index b6412d9..c079aeb 100644
--- a/src/wbc-gtk.c
+++ b/src/wbc-gtk.c
@@ -5020,8 +5020,6 @@ wbc_gtk_set_property (GObject *object, guint property_id,
}
}
-#define UNREF_OBJ(f) do { if (wbcg->f) { g_object_unref (wbcg->f); wbcg->f = NULL; } } while (0)
-
static void
wbc_gtk_finalize (GObject *obj)
{
@@ -5037,19 +5035,19 @@ wbc_gtk_finalize (GObject *obj)
if (wbcg->file_history.merge_id != 0)
gtk_ui_manager_remove_ui (wbcg->ui, wbcg->file_history.merge_id);
- UNREF_OBJ (file_history.actions);
+ g_clear_object (&wbcg->file_history.actions);
if (wbcg->toolbar.merge_id != 0)
gtk_ui_manager_remove_ui (wbcg->ui, wbcg->toolbar.merge_id);
- UNREF_OBJ (toolbar.actions);
+ g_clear_object (&wbcg->toolbar.actions);
if (wbcg->windows.merge_id != 0)
gtk_ui_manager_remove_ui (wbcg->ui, wbcg->windows.merge_id);
- UNREF_OBJ (windows.actions);
+ g_clear_object (&wbcg->windows.actions);
if (wbcg->templates.merge_id != 0)
gtk_ui_manager_remove_ui (wbcg->ui, wbcg->templates.merge_id);
- UNREF_OBJ (templates.actions);
+ g_clear_object (&wbcg->templates.actions);
{
GSList *l, *uis = go_hash_keys (wbcg->custom_uis);
@@ -5063,24 +5061,24 @@ wbc_gtk_finalize (GObject *obj)
g_hash_table_destroy (wbcg->custom_uis);
wbcg->custom_uis = NULL;
- UNREF_OBJ (zoom_vaction);
- UNREF_OBJ (zoom_haction);
- UNREF_OBJ (borders);
- UNREF_OBJ (fore_color);
- UNREF_OBJ (back_color);
- UNREF_OBJ (font_name);
- UNREF_OBJ (redo_haction);
- UNREF_OBJ (redo_vaction);
- UNREF_OBJ (undo_haction);
- UNREF_OBJ (undo_vaction);
- UNREF_OBJ (halignment);
- UNREF_OBJ (valignment);
- UNREF_OBJ (actions);
- UNREF_OBJ (permanent_actions);
- UNREF_OBJ (font_actions);
- UNREF_OBJ (data_only_actions);
- UNREF_OBJ (semi_permanent_actions);
- UNREF_OBJ (ui);
+ g_clear_object (&wbcg->zoom_vaction);
+ g_clear_object (&wbcg->zoom_haction);
+ g_clear_object (&wbcg->borders);
+ g_clear_object (&wbcg->fore_color);
+ g_clear_object (&wbcg->back_color);
+ g_clear_object (&wbcg->font_name);
+ g_clear_object (&wbcg->redo_haction);
+ g_clear_object (&wbcg->redo_vaction);
+ g_clear_object (&wbcg->undo_haction);
+ g_clear_object (&wbcg->undo_vaction);
+ g_clear_object (&wbcg->halignment);
+ g_clear_object (&wbcg->valignment);
+ g_clear_object (&wbcg->actions);
+ g_clear_object (&wbcg->permanent_actions);
+ g_clear_object (&wbcg->font_actions);
+ g_clear_object (&wbcg->data_only_actions);
+ g_clear_object (&wbcg->semi_permanent_actions);
+ g_clear_object (&wbcg->ui);
/* Disconnect signals that would attempt to change things during
* destruction.
@@ -5092,7 +5090,7 @@ wbc_gtk_finalize (GObject *obj)
g_signal_handlers_disconnect_by_func (
G_OBJECT (wbcg->bnotebook),
G_CALLBACK (cb_notebook_switch_page), wbcg);
- UNREF_OBJ (bnotebook);
+ g_clear_object (&wbcg->bnotebook);
g_signal_handlers_disconnect_by_func (
G_OBJECT (wbcg->toplevel),
@@ -5112,10 +5110,10 @@ wbc_gtk_finalize (GObject *obj)
wbcg->font_desc = NULL;
}
- UNREF_OBJ (auto_expr_label);
+ g_clear_object (&wbcg->auto_expr_label);
g_hash_table_destroy (wbcg->visibility_widgets);
- UNREF_OBJ (undo_for_fullscreen);
+ g_clear_object (&wbcg->undo_for_fullscreen);
g_slist_free (wbcg->hide_for_fullscreen);
wbcg->hide_for_fullscreen = NULL;
@@ -5124,13 +5122,11 @@ wbc_gtk_finalize (GObject *obj)
g_free (wbcg->preferred_geometry);
wbcg->preferred_geometry = NULL;
- UNREF_OBJ (gui);
+ g_clear_object (&wbcg->gui);
parent_class->finalize (obj);
}
-#undef UNREF_OBJ
-
/***************************************************************************/
typedef struct {
diff --git a/src/widgets/gnm-dao.c b/src/widgets/gnm-dao.c
index a411c95..17be32a 100644
--- a/src/widgets/gnm-dao.c
+++ b/src/widgets/gnm-dao.c
@@ -105,10 +105,7 @@ gnm_dao_destroy (GtkWidget *widget)
{
GnmDao *gdao = GNM_DAO (widget);
- if (gdao->gui) {
- g_object_unref (gdao->gui);
- gdao->gui = NULL;
- }
+ g_clear_object (&gdao->gui);
((GtkWidgetClass *)(gnm_dao_parent_class))->destroy (widget);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]