[goffice] GOFormat: go_format_unref allows NULL.



commit f2c8522fbabe59ee9d74979407c6a0088d0db9f0
Author: Morten Welinder <terra gnome org>
Date:   Fri Sep 4 20:15:28 2009 -0400

    GOFormat: go_format_unref allows NULL.

 goffice/gtk/go-format-sel.c          |    6 +---
 goffice/utils/go-format.c            |   48 +++++++++++----------------------
 plugins/plot_barcol/gog-1.5d.c       |    6 +---
 plugins/plot_distrib/gog-histogram.c |   13 +++-----
 plugins/plot_surface/gog-xyz.c       |   20 +++++--------
 plugins/plot_xy/gog-xy.c             |   19 +++++--------
 6 files changed, 40 insertions(+), 72 deletions(-)
---
diff --git a/goffice/gtk/go-format-sel.c b/goffice/gtk/go-format-sel.c
index af73754..e8089a8 100644
--- a/goffice/gtk/go-format-sel.c
+++ b/goffice/gtk/go-format-sel.c
@@ -1138,10 +1138,8 @@ go_format_sel_finalize (GObject *obj)
 	g_free (gfs->locale);
 	gfs->locale = NULL;
 
-	if (gfs->format.spec) {
-		go_format_unref (gfs->format.spec);
-		gfs->format.spec = NULL;
-	}
+	go_format_unref (gfs->format.spec);
+	gfs->format.spec = NULL;
 
 	if (gfs->format.size_group) {
 		g_object_unref (gfs->format.size_group);
diff --git a/goffice/utils/go-format.c b/goffice/utils/go-format.c
index ef00203..b471bca 100644
--- a/goffice/utils/go-format.c
+++ b/goffice/utils/go-format.c
@@ -3589,45 +3589,29 @@ _go_number_format_shutdown (void)
 {
 	GHashTable *tmp;
 
-	if (default_percentage_fmt) {
-		go_format_unref (default_percentage_fmt);
-		default_percentage_fmt = NULL;
-	}
+	go_format_unref (default_percentage_fmt);
+	default_percentage_fmt = NULL;
 
-	if (default_money_fmt) {
-		go_format_unref (default_money_fmt);
-		default_money_fmt = NULL;
-	}
+	go_format_unref (default_money_fmt);
+	default_money_fmt = NULL;
 
-	if (default_accounting_fmt) {
-		go_format_unref (default_accounting_fmt);
-		default_accounting_fmt = NULL;
-	}
+	go_format_unref (default_accounting_fmt);
+	default_accounting_fmt = NULL;
 
-	if (default_date_fmt) {
-		go_format_unref (default_date_fmt);
-		default_date_fmt = NULL;
-	}
+	go_format_unref (default_date_fmt);
+	default_date_fmt = NULL;
 
-	if (default_time_fmt) {
-		go_format_unref (default_time_fmt);
-		default_time_fmt = NULL;
-	}
+	go_format_unref (default_time_fmt);
+	default_time_fmt = NULL;
 
-	if (default_date_time_fmt) {
-		go_format_unref (default_date_time_fmt);
-		default_date_time_fmt = NULL;
-	}
+	go_format_unref (default_date_time_fmt);
+	default_date_time_fmt = NULL;
 
-	if (default_general_fmt) {
-		go_format_unref (default_general_fmt);
-		default_general_fmt = NULL;
-	}
+	go_format_unref (default_general_fmt);
+	default_general_fmt = NULL;
 
-	if (default_empty_fmt) {
-		go_format_unref (default_empty_fmt);
-		default_empty_fmt = NULL;
-	}
+	go_format_unref (default_empty_fmt);
+	default_empty_fmt = NULL;
 
 	tmp = style_format_hash;
 	style_format_hash = NULL;
diff --git a/plugins/plot_barcol/gog-1.5d.c b/plugins/plot_barcol/gog-1.5d.c
index 24a2b05..5ecf6ca 100644
--- a/plugins/plot_barcol/gog-1.5d.c
+++ b/plugins/plot_barcol/gog-1.5d.c
@@ -55,10 +55,8 @@ static GogObjectClass *plot1_5d_parent_klass;
 static void
 gog_plot_1_5d_clear_formats (GogPlot1_5d *plot)
 {
-	if (plot->fmt != NULL) {
-		go_format_unref (plot->fmt);
-		plot->fmt = NULL;
-	}
+	go_format_unref (plot->fmt);
+	plot->fmt = NULL;
 }
 
 static void
diff --git a/plugins/plot_distrib/gog-histogram.c b/plugins/plot_distrib/gog-histogram.c
index 7b9b2cd..823ad4e 100644
--- a/plugins/plot_distrib/gog-histogram.c
+++ b/plugins/plot_distrib/gog-histogram.c
@@ -53,14 +53,11 @@ static GogObjectClass *histogram_plot_parent_klass;
 static void
 gog_histogram_plot_clear_formats (GogHistogramPlot *model)
 {
-	if (model->x.fmt != NULL) {
-		go_format_unref (model->x.fmt);
-		model->x.fmt = NULL;
-	}
-	if (model->y.fmt != NULL) {
-		go_format_unref (model->y.fmt);
-		model->y.fmt = NULL;
-	}
+	go_format_unref (model->x.fmt);
+	model->x.fmt = NULL;
+
+	go_format_unref (model->y.fmt);
+	model->y.fmt = NULL;
 }
 
 static char const *
diff --git a/plugins/plot_surface/gog-xyz.c b/plugins/plot_surface/gog-xyz.c
index 32ac0da..1c4c5bb 100644
--- a/plugins/plot_surface/gog-xyz.c
+++ b/plugins/plot_surface/gog-xyz.c
@@ -151,18 +151,14 @@ gog_xyz_plot_get_y_vals (GogXYZPlot *plot)
 static void
 gog_xyz_plot_clear_formats (GogXYZPlot *plot)
 {
-	if (plot->x.fmt != NULL) {
-		go_format_unref (plot->x.fmt);
-		plot->x.fmt = NULL;
-	}
-	if (plot->y.fmt != NULL) {
-		go_format_unref (plot->y.fmt);
-		plot->y.fmt = NULL;
-	}
-	if (plot->z.fmt != NULL) {
-		go_format_unref (plot->z.fmt);
-		plot->z.fmt = NULL;
-	}
+	go_format_unref (plot->x.fmt);
+	plot->x.fmt = NULL;
+
+	go_format_unref (plot->y.fmt);
+	plot->y.fmt = NULL;
+
+	go_format_unref (plot->z.fmt);
+	plot->z.fmt = NULL;
 }
 
 static void
diff --git a/plugins/plot_xy/gog-xy.c b/plugins/plot_xy/gog-xy.c
index 3878c33..550d462 100644
--- a/plugins/plot_xy/gog-xy.c
+++ b/plugins/plot_xy/gog-xy.c
@@ -73,14 +73,11 @@ static void gog_2d_plot_adjust_bounds (Gog2DPlot *model, double *x_min, double *
 static void
 gog_2d_plot_clear_formats (Gog2DPlot *plot2d)
 {
-	if (plot2d->x.fmt != NULL) {
-		go_format_unref (plot2d->x.fmt);
-		plot2d->x.fmt = NULL;
-	}
-	if (plot2d->y.fmt != NULL) {
-		go_format_unref (plot2d->y.fmt);
-		plot2d->y.fmt = NULL;
-	}
+	go_format_unref (plot2d->x.fmt);
+	plot2d->x.fmt = NULL;
+
+	go_format_unref (plot2d->y.fmt);
+	plot2d->y.fmt = NULL;
 }
 
 static void
@@ -604,10 +601,8 @@ static GogObjectClass *map_parent_klass;
 static void
 gog_xy_color_plot_clear_formats (GogXYColorPlot *map)
 {
-	if (map->z.fmt != NULL) {
-		go_format_unref (map->z.fmt);
-		map->z.fmt = NULL;
-	}
+	go_format_unref (map->z.fmt);
+	map->z.fmt = NULL;
 }
 
 static void



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]