--- gst/schedulers/gstoptimalscheduler.c.orig	2004-05-18 10:19:08.000000000 -0400
+++ gst/schedulers/gstoptimalscheduler.c	2004-05-18 10:30:54.000000000 -0400
@@ -1042,22 +1042,26 @@
     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) {
       GstElement *e = (GstElement *) l->data;
 
+      gst_object_ref (GST_OBJECT (e));
       if (e->pre_run_func)
         e->pre_run_func (e);
     }
+    lcopy = g_slist_copy(group->elements);
 
     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));
     }
 
   }
