Subject: pkg/31825: guppi bug causes errors in gnucash barcharts
To: None <pkg-manager@netbsd.org, gnats-admin@netbsd.org,>
From: Richard Earnshaw <rearnsha@buzzard.freeserve.co.uk>
List: pkgsrc-bugs
Date: 10/15/2005 13:21:00
>Number:         31825
>Category:       pkg
>Synopsis:       guppi bug causes errors in gnucash barcharts
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Oct 15 13:21:00 +0000 2005
>Originator:     Richard Earnshaw
>Release:        NetBSD 3.0_BETA
>Organization:
	self
	
>Environment:
	
	
System: NetBSD merlin.buzzard.freeserve.co.uk 3.0_BETA NetBSD 3.0_BETA (MERLIN) #0: Sat Aug 20 18:19:56 BST 2005 rearnsha@merlin.buzzard.freeserve.co.uk:/work/rearnsha/netbsd/build/netbsd-3/i386/src/sys/arch/i386/compile/MERLIN i386
Architecture: i386
Machine: i386
>Description:
	
	gnucash uses libguppi do do various graphical rendering activities.  
	A bug in the libraries bar-charting code means that the labels
	on bar-charts are attached to the wrong objects, so attempting
	to open a sub-chart results in the wrong entry being selected
	(click on the first entry and the last one is displayed, click on
	the last and the first).

	Unfortunately, it would appear that guppi is no-longer being actively
	maintained, so there might not be a further release of this library.
	The attached patch is included in several source RPMS for Linux
	(and apparently was committed to the guppi source CVS).

>How-To-Repeat:
	run gnucash and create a bar chart with sub-accounts.  Click on
	the colour spots in the legend.  The wrong sub-chart or account
	is displayed.
	
>Fix:
	Apply this patch to math/guppi
--- libguppitank/guppi-object-barchart.c	2003-05-30 21:21:16.000000000 +0200
+++ libguppitank/guppi-object-barchart.c	2003-05-30 21:21:26.000000000 +0200
@@ -410,6 +410,7 @@
   GuppiElementState *left_axis_state = NULL;
   GuppiElementState *frame_state = NULL;
   GuppiColorPalette *color_palette = NULL;
+  GuppiColorPalette *color_palette_legend = NULL;
   GuppiDataTable *data_table;
   GnomeFont *font;
   
@@ -446,11 +447,13 @@
   /* FIXME: check for construction of legends. */
 
   if (obar->legend_view && obar->col_labels) {
-    add_col_labels (obar, data_table, obar->data_cols, obar->col_labels, FALSE);
+    add_col_labels (obar, data_table, obar->data_cols, obar->col_labels, 
+		    obar->legend_reversed);
   }
 
   if (obar->col_colors) {
     color_palette = build_bar_colors (obar, FALSE);
+    color_palette_legend = build_bar_colors (obar, obar->legend_reversed);
   }
   
   guppi_element_state_set (barchart_state,
@@ -497,7 +500,7 @@
 
     guppi_element_state_set (legend_state,
 			     "labels", data_table,
-			     "swatch_colors", color_palette,
+			     "swatch_colors", color_palette_legend,
 			     "label_font", font,
 			     NULL);
   }
@@ -505,6 +508,8 @@
  
   /* clean up */
   
+  guppi_unref (color_palette);
+  guppi_unref (color_palette_legend);
   guppi_unref (barchart_state);
   guppi_unref (legend_state);			   
   guppi_unref (bottom_axis_state);
@@ -525,6 +530,7 @@
 
   GuppiDataTable *data_table;
   GuppiColorPalette *color_palette = NULL;
+  GuppiColorPalette *color_palette_legend = NULL;
 
   GuppiElementState *barchart_state;
   GuppiElementState *legend_state = NULL;
@@ -560,7 +566,8 @@
   }
 
   if (obar->col_labels) {
-    add_col_labels (obar, data_table, obar->data_cols, obar->col_labels, FALSE);
+    add_col_labels (obar, data_table, obar->data_cols, obar->col_labels, 
+		    obar->legend_reversed);
   }
 
 
@@ -568,6 +575,7 @@
 
   if (obar->col_colors) {
     color_palette = build_bar_colors (obar, FALSE);
+    color_palette_legend = build_bar_colors (obar, obar->legend_reversed);
   }
 
   barchart_state = guppi_element_state_new ("barchart",
@@ -620,7 +628,8 @@
 
     legend_state = guppi_element_state_new ("legend",
 					    "labels", data_table,
-					    "swatch_colors", color_palette,
+					    "swatch_colors", 
+					    color_palette_legend,
 					    "label_font", font,
 					    NULL);
 
@@ -669,6 +678,8 @@
   /* Clean up after ourselves... */
 
   guppi_unref (data_table);
+  guppi_unref (color_palette);
+  guppi_unref (color_palette_legend);
 
   guppi_unref (barchart_state);
   guppi_unref (bottom_axis_state);


>Unformatted: