Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 1934)
+++ trunk/MagicSoft/Mars/Changelog	(revision 1935)
@@ -1,3 +1,14 @@
                                                  -*-*- END OF LINE -*-*-
+
+ 2003/04/10: Thomas Bretz
+ 
+   * mbase/MContinue.[h,cc]:
+     - changed, so that also a filter given as a pointer is added to
+       the tasklist automatically
+ 
+   * mbase/MTaskList.[h,cc]:
+     - added RemoveFromList-function
+
+
 
  2003/04/09: Thomas Bretz
Index: trunk/MagicSoft/Mars/mbase/MContinue.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MContinue.cc	(revision 1934)
+++ trunk/MagicSoft/Mars/mbase/MContinue.cc	(revision 1935)
@@ -105,20 +105,9 @@
 // --------------------------------------------------------------------------
 //
-//  In case the filter was created automatically, PreProcess tries to find
-//  the tasklist MTaskList, adds the filter before this instance to the
-//  tasklist and preprocesses the filter.
+//  PreProcess tries to find the tasklist MTaskList, adds the filter
+//  before this instance to the tasklist and preprocesses the filter.
 //
 Bool_t MContinue::PreProcess(MParList *list)
 {
-    if (!TestBit(kIsOwner))
-        return kTRUE;
-
-    MTaskList *tlist = (MTaskList*)list->FindObject("MTaskList");
-    if (!tlist)
-    {
-        *fLog << err << dbginf << "ERROR - Tasklist 'MTaskList' not found... abort." << endl;
-        return kFALSE;
-    }
-
     if (!GetFilter())
     {
@@ -127,5 +116,18 @@
     }
 
-    if (!tlist->AddToListBefore(GetFilter(), this))
+    fTaskList = (MTaskList*)list->FindObject("MTaskList");
+    if (!fTaskList)
+    {
+        *fLog << err << dbginf << "ERROR - Tasklist 'MTaskList' not found... abort." << endl;
+        return kFALSE;
+    }
+
+    if (fTaskList->FindObject(GetFilter()))
+    {
+        *fLog << warn << dbginf << "WARNING - The filter is already in the tasklist..." << endl;
+        return kTRUE;
+    }
+
+    if (!fTaskList->AddToListBefore(GetFilter(), this))
     {
         *fLog << err << dbginf << "ERROR - Adding filter before MContinue... abort." << endl;
@@ -133,4 +135,24 @@
     }
 
+    SetBit(kFilterIsPrivate);
+
     return GetFilter()->CallPreProcess(list);
 }
+
+// --------------------------------------------------------------------------
+//
+// If the filter was added to the tasklist automatically it is removed
+// from the tasklist.
+//
+Bool_t MContinue::PostProcess()
+{
+    if (!TestBit(kFilterIsPrivate))
+        return kTRUE;
+
+    if (fTaskList->RemoveFromList(GetFilter()))
+        return kTRUE;
+
+    *fLog << err << "ERROR: MContinue::PostProcess - Cannot remove Filter from tasklist" << endl;
+
+    return kFALSE;
+}
Index: trunk/MagicSoft/Mars/mbase/MContinue.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MContinue.h	(revision 1934)
+++ trunk/MagicSoft/Mars/mbase/MContinue.h	(revision 1935)
@@ -16,12 +16,16 @@
 
 class MFilter;
+class MTaskList;
 
 class MContinue : public MTask
 {
 private:
+    MTaskList *fTaskList;  //! pointer to the present tasklist
+
     Bool_t PreProcess(MParList *list);
     Bool_t Process() { return kCONTINUE; }
+    Bool_t PostProcess();
 
-    enum { kIsOwner = BIT(14) };
+    enum { kIsOwner = BIT(14), kFilterIsPrivate = BIT(15) };
 
 public:
Index: trunk/MagicSoft/Mars/mbase/MTaskList.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MTaskList.cc	(revision 1934)
+++ trunk/MagicSoft/Mars/mbase/MTaskList.cc	(revision 1935)
@@ -754,2 +754,22 @@
     return kTRUE;
 }
+
+// --------------------------------------------------------------------------
+//
+// Removes a task from the tasklist. Returns kFALSE if the object was not
+// found in the list.
+//
+Bool_t MTaskList::RemoveFromList(MTask *task)
+{
+    TObject *obj = fTasks->Remove(task);
+
+    //
+    // If the task was found in the list try to remove it from the second
+    // list, too.
+    //
+    if (obj)
+        fTasksProcess.Remove(task);
+
+    return obj ? kTRUE : kFALSE;
+
+}
Index: trunk/MagicSoft/Mars/mbase/MTaskList.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MTaskList.h	(revision 1934)
+++ trunk/MagicSoft/Mars/mbase/MTaskList.h	(revision 1935)
@@ -49,4 +49,6 @@
     Bool_t AddToList(MTask *task, const char *tType="All");
 
+    Bool_t RemoveFromList(MTask *task);
+
     TObject *FindObject(const char *name) const;
     TObject *FindObject(const TObject *obj) const;
