Blob Blame History Raw
diff -up gnome-desktop-2.22.0/libgnome-desktop/gnome-bg.c.refcount-slideshow gnome-desktop-2.22.0/libgnome-desktop/gnome-bg.c
--- gnome-desktop-2.22.0/libgnome-desktop/gnome-bg.c.refcount-slideshow	2008-04-04 11:50:15.000000000 -0400
+++ gnome-desktop-2.22.0/libgnome-desktop/gnome-bg.c	2008-04-04 11:50:23.000000000 -0400
@@ -820,6 +820,7 @@ gnome_bg_set_pixmap_as_root (GdkScreen *
 /* Implementation of the pixbuf cache */
 struct _SlideShow
 {
+	gint ref_count;
 	double start_time;
 	double total_duration;
 
@@ -834,7 +835,8 @@ struct _SlideShow
 
 static SlideShow *read_slideshow_file (const char *filename,
 				       GError     **err);
-static void       slideshow_free      (SlideShow  *show);
+static void       slideshow_ref       (SlideShow  *show);
+static void       slideshow_unref     (SlideShow  *show);
 
 static double
 now (void)
@@ -929,7 +931,7 @@ file_cache_entry_delete (FileCacheEntry 
 		g_object_unref (ent->u.pixbuf);
 		break;
 	case SLIDESHOW:
-		slideshow_free (ent->u.slideshow);
+		slideshow_unref (ent->u.slideshow);
 		break;
 	case THUMBNAIL:
 		g_object_unref (ent->u.thumbnail);
@@ -1198,7 +1200,11 @@ create_img_thumbnail (GnomeBG           
 			
 			if (show) {
 				double alpha;
-				Slide *slide = get_current_slide (show, &alpha);
+				Slide *slide;
+
+				slideshow_ref (show);
+
+				slide = get_current_slide (show, &alpha);
 
 				if (slide->fixed) {
 					GdkPixbuf *tmp;
@@ -1238,6 +1244,8 @@ create_img_thumbnail (GnomeBG           
 				}
 
 				ensure_timeout (bg, slide);
+
+				slideshow_unref (show);
 			}
 		}
 
@@ -1309,7 +1317,11 @@ get_pixbuf (GnomeBG *bg)
 
 			if (show) {
 				double alpha;
-				Slide *slide = get_current_slide (show, &alpha);
+				Slide *slide;
+
+				slideshow_ref (show);
+
+				slide = get_current_slide (show, &alpha);
 
 				if (slide->fixed) {
 					FileSize *size;
@@ -1332,6 +1344,8 @@ get_pixbuf (GnomeBG *bg)
 				}
 
 				ensure_timeout (bg, slide);
+
+				slideshow_unref (show);
 			}
 		}
 	}
@@ -1819,12 +1833,22 @@ handle_text (GMarkupParseContext *contex
 }
 
 static void
-slideshow_free (SlideShow *show)
+slideshow_ref (SlideShow *show)
+{
+	show->ref_count++;
+}
+
+static void
+slideshow_unref (SlideShow *show)
 {
 	GList *list;
 	GSList *slist;
 	FileSize *size;
 	
+	show->ref_count--;
+	if (show->ref_count > 0)
+		return;
+
 	for (list = show->slides->head; list != NULL; list = list->next) {
 		Slide *slide = list->data;
 		for (slist = slide->file1; slist != NULL; slist = slist->next) {
@@ -1933,6 +1957,7 @@ read_slideshow_file (const char *uri,
 	g_object_unref (file);
 	
 	show = g_new0 (SlideShow, 1);
+	show->ref_count = 1;
 	threadsafe_localtime ((time_t)0, &show->start_tm);
 	show->stack = g_queue_new ();
 	show->slides = g_queue_new ();
@@ -1940,13 +1965,13 @@ read_slideshow_file (const char *uri,
 	context = g_markup_parse_context_new (&parser, 0, show, NULL);
 	
 	if (!g_markup_parse_context_parse (context, contents, len, err)) {
-		slideshow_free (show);
+		slideshow_unref (show);
 		show = NULL;
 	}
 	
 	if (show) {
 		if (!g_markup_parse_context_end_parse (context, err)) {
-			slideshow_free (show);
+			slideshow_unref (show);
 			show = NULL;
 		}
 	}