After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 658194 - Criticals when saving chart as ODF
Criticals when saving chart as ODF
Status: RESOLVED FIXED
Product: Gnumeric
Classification: Applications
Component: Charting
git master
Other Linux
: Normal normal
: ---
Assigned To: Jean Bréfort
Jody Goldberg
Depends on:
Blocks:
 
 
Reported: 2011-09-04 20:34 UTC by Andreas J. Guelzow
Modified: 2011-09-06 08:26 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
sample file (17.05 KB, application/gnumeric)
2011-09-04 20:34 UTC, Andreas J. Guelzow
  Details
Proposed patch (1.15 KB, patch)
2011-09-06 06:53 UTC, Jean Bréfort
committed Details | Review

Description Andreas J. Guelzow 2011-09-04 20:34:37 UTC
Created attachment 195637 [details]
sample file

open the attached file and try to save it as an ODF file with foreign elements. You see:

(gnumeric:25987): GLib-CRITICAL **: g_hash_table_lookup: assertion `hash_table != NULL' failed

** (gnumeric:25987): CRITICAL **: gog_smoothed_curve_dataset_get_elem: assertion `dim_i == -1' failed

** (gnumeric:25987): CRITICAL **: gog_smoothed_curve_dataset_get_elem: assertion `dim_i == -1' failed

The hash_table critical appears as a result of an attempt to determine whether a regression curve or trend line is shown.
Comment 1 Jean Bréfort 2011-09-04 20:53:19 UTC
How do we try to know if it is a regression curve or a smoothed curve? GOG_IS_REG_CURVE would tell if it is a regression curve. GOG_IS_SMOOTHED_CURVE is the other possible test.
Comment 2 Andreas J. Guelzow 2011-09-06 04:04:58 UTC
Let's worry about the first warning. We have in openoffice-write.c:
------------------------------------------------------------------
GSList *l, *regressions = gog_object_get_children
		(series, role);
char *str;

for (l = regressions; l != NULL && l->data != NULL; l = l->next) {
	GOData const *bd;
	GogObject const *regression = l->data;
	GogObject const *equation
		= gog_object_get_child_by_name (regression, "Equation");
...
if (equation != NULL) {
		GObjectClass *klass = G_OBJECT_GET_CLASS (equation);
...
------------------------------------------------------------------

The "(gnumeric:25987): GLib-CRITICAL **: g_hash_table_lookup: assertion `hash_table != NULL' failed" is triggered by the gog_object_get_child_by_name. We ar elater checking whether equation is null, unfortunately we get the critical rather than just a NULL.
Comment 3 Andreas J. Guelzow 2011-09-06 04:09:55 UTC
The second critical appears in the same code snippet:
--------------------------------------------------------------
GSList *l, *regressions = gog_object_get_children
	(series, role);
char *str;

for (l = regressions; l != NULL && l->data != NULL; l = l->next) {
	GOData const *bd;
	GogObject const *regression = l->data;
	GogObject const *equation
		= gog_object_get_child_by_name (regression, "Equation");

	str = odf_get_gog_style_name_from_obj
		(GOG_OBJECT (regression));
	gsf_xml_out_start_element
		(state->xml,
		 (l == regressions) ? CHART "regression-curve"
		 : GNMSTYLE "regression-curve");
	gsf_xml_out_add_cstr (state->xml, CHART "style-name", str);

	if (state->with_extension) {
		/* Upper and lower bounds */
		bd = gog_dataset_get_dim (GOG_DATASET (regression), 0);
		if (bd != NULL)
...

--------------------------------------------------------------

It is triggered by the 
gog_dataset_get_dim (GOG_DATASET (regression), 0);

again a straight NULL would be preferable.
Comment 4 Jean Bréfort 2011-09-06 06:29:32 UTC
For the last comment, you should never call gog_dataset_get_dim () if you don't know which are the correct indices (this is a feature).
gog_dataset_dims() tells which are the first and last that you can use.
Comment 5 Jean Bréfort 2011-09-06 06:53:35 UTC
Created attachment 195753 [details] [review]
Proposed patch

Please, test with this patch.
Comment 6 Andreas J. Guelzow 2011-09-06 08:01:07 UTC
Review of attachment 195753 [details] [review]:

please commit
Comment 7 Jean Bréfort 2011-09-06 08:26:57 UTC
This problem has been fixed in the development version. The fix will be available in the next major software release. Thank you for your bug report.