Index: gstoptimalscheduler.c
===================================================================
RCS file: /cvs/gstreamer/gstreamer/gst/schedulers/gstoptimalscheduler.c,v
retrieving revision 1.92
diff -u -B -p -u -B -p -r1.92 gstoptimalscheduler.c
--- gstoptimalscheduler.c	16 Jul 2004 16:02:12 -0000	1.92
+++ gstoptimalscheduler.c	19 Jul 2004 16:20:17 -0000
@@ -1120,23 +1120,28 @@ schedule_group (GstOptSchedulerGroup * g
     GST_INFO ("not scheduling group %p without schedulefunc", group);
     return FALSE;
   } else {
-    GSList *l;
+    GSList *l, *lcopy;
 
-    for (l = group->elements; l; l = l->next) {
+    lcopy = g_slist_copy (group->elements);
+    for (l = lcopy; l; l = l->next) {
       GstElement *e = (GstElement *) l->data;
 
+      gst_object_ref (GST_OBJECT (e));
       if (e->pre_run_func)
         e->pre_run_func (e);
     }
 
     group->schedulefunc (group->argc, group->argv);
 
-    for (l = group->elements; l; l = l->next) {
+    for (l = lcopy; l; l = l->next) {
       GstElement *e = (GstElement *) l->data;
 
       if (e->post_run_func)
         e->post_run_func (e);
+
+      gst_object_unref (GST_OBJECT (e));
     }
+    g_slist_free (lcopy);
 
   }
   return TRUE;
