Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/beast/ChangeLog,v
retrieving revision 1.1043
diff -u -p -r1.1043 ChangeLog
--- ChangeLog	19 May 2006 21:33:32 -0000	1.1043
+++ ChangeLog	20 May 2006 10:03:35 -0000
@@ -1,3 +1,13 @@
+Sat May 20 11:52:11 2006  Stefan Westerfeld  <stefan@space.twc.de>
+
+	* beast-gtk/bstcanvaslink.c:
+	* beast-gtk/bstcanvassource.c: Older libgnomecanvas versions had a
+	bug (they don't clear their item->canvas pointers properly), for which
+	a workaround was present. However, newer libgnomecanvas versions no
+	longer have this bug, which caused problems with the old workaround.
+	So this is an upgraded workaround which should work with both: older
+	and newer libgnomecanvas versions. For details see also #340437.
+
 Fri May 19 17:51:33 2006  Tim Janik  <timj@gtk.org>
 
 	* slowtests/audio/Makefile.am: fixed audio test rules, run audio
Index: beast-gtk/bstcanvaslink.c
===================================================================
RCS file: /cvs/gnome/beast/beast-gtk/bstcanvaslink.c,v
retrieving revision 1.29
diff -u -p -r1.29 bstcanvaslink.c
--- beast-gtk/bstcanvaslink.c	10 Dec 2004 11:19:09 -0000	1.29
+++ beast-gtk/bstcanvaslink.c	20 May 2006 10:03:36 -0000
@@ -77,7 +77,9 @@ bst_canvas_link_new (GnomeCanvasGroup *g
   item = gnome_canvas_item_new (group,
 				BST_TYPE_CANVAS_LINK,
 				NULL);
-  g_object_ref (item->canvas);  /* GnomeCanvasItem doesn't properly clear its pointers */
+
+  /* some GnomeCanvasItem versions don't properly clear their pointers */
+  g_object_set_data_full (item, "bst-workaround-canvas-ref", g_object_ref (item->canvas), g_object_unref);
   bst_background_handler1_add (bst_canvas_link_build_async, g_object_ref (item), NULL);
   return item;
 }
@@ -327,9 +329,10 @@ bst_canvas_link_build_async (gpointer da
                                         NULL);
       bst_canvas_link_update (clink);
     }
-  GnomeCanvas *canvas = item->canvas;
+  GnomeCanvas *canvas = g_object_steal_data (item, "bst-workaround-canvas-ref");
   g_object_unref (item);
-  g_object_unref (canvas);      /* canvases don't properly protect their items */
+  if (canvas)
+    g_object_unref (canvas);      /* canvases don't properly protect their items */
   return FALSE;
 }
 
Index: beast-gtk/bstcanvassource.c
===================================================================
RCS file: /cvs/gnome/beast/beast-gtk/bstcanvassource.c,v
retrieving revision 1.68
diff -u -p -r1.68 bstcanvassource.c
--- beast-gtk/bstcanvassource.c	19 Dec 2004 01:22:38 -0000	1.68
+++ beast-gtk/bstcanvassource.c	20 May 2006 10:03:36 -0000
@@ -872,9 +872,10 @@ bst_canvas_source_build_async (gpointer 
           return TRUE;
         }
     }
-  GnomeCanvas *canvas = item->canvas;
+  GnomeCanvas *canvas = g_object_steal_data (item, "bst-workaround-canvas-ref");
   g_object_unref (item);
-  g_object_unref (canvas);      /* canvases don't properly protect their items */
+  if (canvas)
+    g_object_unref (canvas);      /* canvases don't properly protect their items */
   return FALSE;
 }
 
@@ -908,8 +909,10 @@ bst_canvas_source_build (BstCanvasSource
   csource->built_ochannels = FALSE;
   csource->built_ihints = FALSE;
   csource->built_ohints = FALSE;
-  /* asyncronously rebuild contents */
-  g_object_ref (GNOME_CANVAS_ITEM (csource)->canvas);   /* GnomeCanvasItem doesn't properly clear its pointers */
+  /* asynchronously rebuild contents */
+  /* some GnomeCanvasItem versions don't properly clear their pointers */
+  GnomeCanvasItem *csource_item = GNOME_CANVAS_ITEM (csource);
+  g_object_set_data_full (csource_item, "bst-workaround-canvas-ref", g_object_ref (csource_item->canvas), g_object_unref);
   bst_background_handler2_add (bst_canvas_source_build_async, g_object_ref (csource), NULL);
 }
 
