[goffice] Fixed GOFormat leak and a few other issues.
- From: Jean Bréfort <jbrefort src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [goffice] Fixed GOFormat leak and a few other issues.
- Date: Thu, 15 Aug 2013 17:12:39 +0000 (UTC)
commit 79b29ecfbded52c04b5295ae831bb1f7fb25b719
Author: Jean Brefort <jean brefort normalesup org>
Date: Thu Aug 15 19:10:59 2013 +0200
Fixed GOFormat leak and a few other issues.
ChangeLog | 9 +++++++
plugins/plot_xy/gog-xy-dropbar.c | 40 +++++++++++++++------------------
plugins/plot_xy/gog-xy-minmax.c | 44 +++++++++++++++++++++---------------
plugins/plot_xy/plot-types.xml.in | 16 ++++++------
4 files changed, 61 insertions(+), 48 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index fa57fdc..d9017d4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
2013-08-15 Jean Brefort <jean brefort normalesup org>
+ * plugins/plot_xy/gog-xy-dropbar.c (gog_xy_dropbar_plot_update): fixed x/y
+ confusion.
+ * plugins/plot_xy/gog-xy-minmax.c (gog_xy_minmax_plot_update): ditto,
+ (gog_xy_minmax_plot_finalize), (gog_xy_minmax_plot_class_init): unref the
+ formats. See bug 705913, comment 6.
+ * plugins/plot_xy/plot-types.xml.in: fixed min max plots types.
+
+2013-08-15 Jean Brefort <jean brefort normalesup org>
+
* plugins/plot_surface/gog-xyz.c (gog_xyz_plot_update_3d),
(gog_xyz_plot_get_x_vals), (gog_xyz_plot_get_y_vals): fixed memory leaks.
diff --git a/plugins/plot_xy/gog-xy-dropbar.c b/plugins/plot_xy/gog-xy-dropbar.c
index 5aaa57f..ecf1151 100644
--- a/plugins/plot_xy/gog-xy-dropbar.c
+++ b/plugins/plot_xy/gog-xy-dropbar.c
@@ -166,15 +166,14 @@ gog_xy_dropbar_plot_update (GogObject *obj)
GogSeries const *series = NULL;
double x_min, x_max, y_min, y_max, tmp_min, tmp_max;
GSList *ptr;
- gboolean is_discrete = FALSE;
- struct axes_data *realx, *realy;
+ unsigned xaxis, yaxis;
if (model->horizontal) {
- realx = &model->y;
- realy = &model->x;
+ xaxis = 1;
+ yaxis = 0;
} else {
- realx = &model->x;
- realy = &model->y;
+ xaxis = 0;
+ yaxis = 1;
}
x_min = y_min = DBL_MAX;
x_max = y_max = -DBL_MAX;
@@ -187,9 +186,9 @@ gog_xy_dropbar_plot_update (GogObject *obj)
go_data_get_bounds (series->values[1].data, &tmp_min, &tmp_max);
if (y_min > tmp_min) y_min = tmp_min;
if (y_max < tmp_max) y_max = tmp_max;
- if (realy->fmt == NULL) {
- realy->fmt = go_data_preferred_fmt (series->values[1].data);
- realy->date_conv = go_data_date_conv (series->values[1].data);
+ if (model->y.fmt == NULL) {
+ model->y.fmt = go_data_preferred_fmt (series->values[1].data);
+ model->y.date_conv = go_data_date_conv (series->values[1].data);
}
go_data_get_bounds (series->values[2].data, &tmp_min, &tmp_max);
if (y_min > tmp_min)
@@ -204,16 +203,13 @@ gog_xy_dropbar_plot_update (GogObject *obj)
tmp_min > tmp_max) {
tmp_min = 0;
tmp_max = go_data_get_vector_size (series->values[1].data);
-
- is_discrete = TRUE;
} else if (model->x.fmt == NULL) {
- realx->fmt = go_data_preferred_fmt (series->values[0].data);
- realy->date_conv = go_data_date_conv (series->values[0].data);
+ model->x.fmt = go_data_preferred_fmt (series->values[0].data);
+ model->x.date_conv = go_data_date_conv (series->values[0].data);
}
} else {
tmp_min = 0;
tmp_max = go_data_get_vector_size (series->values[1].data);
- is_discrete = TRUE;
}
if (x_min > tmp_min)
@@ -225,15 +221,15 @@ gog_xy_dropbar_plot_update (GogObject *obj)
tmp_max = (x_max - x_min) * model->width / 200.;
x_min -= tmp_max;
x_max += tmp_max;
- if (realx->minima != x_min || realx->maxima != x_max) {
- realx->minima = x_min;
- realx->maxima = x_max;
- gog_axis_bound_changed (model->base.axis[0], GOG_OBJECT (model));
+ if (model->x.minima != x_min || model->x.maxima != x_max) {
+ model->x.minima = x_min;
+ model->x.maxima = x_max;
+ gog_axis_bound_changed (model->base.axis[xaxis], GOG_OBJECT (model));
}
- if (realy->minima != y_min || realy->maxima != y_max) {
- realy->minima = y_min;
- realy->maxima = y_max;
- gog_axis_bound_changed (model->base.axis[1], GOG_OBJECT (model));
+ if (model->y.minima != y_min || model->y.maxima != y_max) {
+ model->y.minima = y_min;
+ model->y.maxima = y_max;
+ gog_axis_bound_changed (model->base.axis[yaxis], GOG_OBJECT (model));
}
gog_object_emit_changed (GOG_OBJECT (obj), FALSE);
if (gog_xy_dropbar_parent_klass->update)
diff --git a/plugins/plot_xy/gog-xy-minmax.c b/plugins/plot_xy/gog-xy-minmax.c
index a64e211..a934449 100644
--- a/plugins/plot_xy/gog-xy-minmax.c
+++ b/plugins/plot_xy/gog-xy-minmax.c
@@ -173,14 +173,14 @@ gog_xy_minmax_plot_update (GogObject *obj)
GogSeries const *series = NULL;
double x_min, x_max, y_min, y_max, tmp_min, tmp_max;
GSList *ptr;
- struct axes_data *realx, *realy;
+ unsigned xaxis, yaxis;
if (model->horizontal) {
- realx = &model->y;
- realy = &model->x;
+ xaxis = 1;
+ yaxis = 0;
} else {
- realx = &model->x;
- realy = &model->y;
+ xaxis = 0;
+ yaxis = 1;
}
x_min = y_min = DBL_MAX;
x_max = y_max = -DBL_MAX;
@@ -193,9 +193,9 @@ gog_xy_minmax_plot_update (GogObject *obj)
go_data_get_bounds (series->values[1].data, &tmp_min, &tmp_max);
if (y_min > tmp_min) y_min = tmp_min;
if (y_max < tmp_max) y_max = tmp_max;
- if (realy->fmt == NULL) {
- realy->fmt = go_data_preferred_fmt (series->values[1].data);
- realy->date_conv = go_data_date_conv (series->values[1].data);
+ if (model->y.fmt == NULL) {
+ model->y.fmt = go_data_preferred_fmt (series->values[1].data);
+ model->y.date_conv = go_data_date_conv (series->values[1].data);
}
go_data_get_bounds (series->values[2].data, &tmp_min, &tmp_max);
if (y_min > tmp_min)
@@ -212,8 +212,8 @@ gog_xy_minmax_plot_update (GogObject *obj)
tmp_max = go_data_get_vector_size (series->values[1].data);
} else if (model->x.fmt == NULL) {
- realx->fmt = go_data_preferred_fmt (series->values[0].data);
- realy->date_conv = go_data_date_conv (series->values[0].data);
+ model->x.fmt = go_data_preferred_fmt (series->values[0].data);
+ model->x.date_conv = go_data_date_conv (series->values[0].data);
}
} else {
tmp_min = 0;
@@ -225,15 +225,15 @@ gog_xy_minmax_plot_update (GogObject *obj)
if (x_max < tmp_max)
x_max = tmp_max;
}
- if (realx->minima != x_min || realx->maxima != x_max) {
- realx->minima = x_min;
- realx->maxima = x_max;
- gog_axis_bound_changed (model->base.axis[0], GOG_OBJECT (model));
+ if (model->x.minima != x_min || model->x.maxima != x_max) {
+ model->x.minima = x_min;
+ model->x.maxima = x_max;
+ gog_axis_bound_changed (model->base.axis[xaxis], GOG_OBJECT (model));
}
- if (realy->minima != y_min || realy->maxima != y_max) {
- realy->minima = y_min;
- realy->maxima = y_max;
- gog_axis_bound_changed (model->base.axis[1], GOG_OBJECT (model));
+ if (model->y.minima != y_min || model->y.maxima != y_max) {
+ model->y.minima = y_min;
+ model->y.maxima = y_max;
+ gog_axis_bound_changed (model->base.axis[yaxis], GOG_OBJECT (model));
}
gog_object_emit_changed (GOG_OBJECT (obj), FALSE);
if (gog_xy_minmax_parent_klass->update)
@@ -277,6 +277,13 @@ gog_xy_minmax_axis_get_bounds (GogPlot *plot, GogAxisType axis,
}
static void
+gog_xy_minmax_plot_finalize (GObject *obj)
+{
+ gog_xy_minmax_plot_clear_formats (GOG_XY_MINMAX_PLOT (obj));
+ ((GObjectClass *) gog_xy_minmax_parent_klass)->finalize (obj);
+}
+
+static void
gog_xy_minmax_plot_class_init (GogPlotClass *plot_klass)
{
GObjectClass *gobject_klass = (GObjectClass *) plot_klass;
@@ -285,6 +292,7 @@ gog_xy_minmax_plot_class_init (GogPlotClass *plot_klass)
gobject_klass->set_property = gog_xy_minmax_plot_set_property;
gobject_klass->get_property = gog_xy_minmax_plot_get_property;
+ gobject_klass->finalize = gog_xy_minmax_plot_finalize;
g_object_class_install_property (gobject_klass, XY_MINMAX_PROP_HORIZONTAL,
g_param_spec_boolean ("horizontal",
diff --git a/plugins/plot_xy/plot-types.xml.in b/plugins/plot_xy/plot-types.xml.in
index bbcc03f..e791eca 100644
--- a/plugins/plot_xy/plot-types.xml.in
+++ b/plugins/plot_xy/plot-types.xml.in
@@ -106,20 +106,20 @@
<property name="default-style-has-markers">False</property>
<property name="guru-hints">backplane</property>
</Type>
- <Type _name="Scattered Marked Vertical Min Max Lines" row="1" col="4"
+ <Type _name="Scattered Horizontal Min Max Lines" row="1" col="4"
engine="GogXYMinMaxPlot" family="MinMax"
- _description="Vertical Min Max lines with markers and a continuous X-axis."
+ _description="Horizontal Min Max lines with continuous Y-axis."
sample_image_file="res:go:plot_xy/chart_minmax_1_4.png">
- <property name="horizontal">False</property>
- <property name="default-style-has-markers">True</property>
+ <property name="horizontal">True</property>
+ <property name="default-style-has-markers">False</property>
<property name="guru-hints">backplane</property>
</Type>
- <Type _name="Scattered Horizontal Min Max Lines" row="2" col="3"
+ <Type _name="Scattered Marked Vertical Min Max Lines" row="2" col="3"
engine="GogXYMinMaxPlot" family="MinMax"
- _description="Horizontal Min Max lines with continuous Y-axis."
+ _description="Vertical Min Max lines with markers and a continuous X-axis."
sample_image_file="res:go:plot_xy/chart_minmax_2_3.png">
- <property name="horizontal">True</property>
- <property name="default-style-has-markers">False</property>
+ <property name="horizontal">False</property>
+ <property name="default-style-has-markers">True</property>
<property name="guru-hints">backplane</property>
</Type>
<Type _name="Scattered Marked Horizontal Min Max Lines" row="2" col="4"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]