[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-bugs-dist
Subject:    Bug#29997: More todo crash stuff
From:       Timothy Vail <tdv2847 () rit ! edu>
Date:       2002-04-01 11:10:01
[Download RAW message or body]

Okay, I looked into the problem, and I found a couple of quick and dirty ways 
to do it...
1. You can refuse to delete the children (this is faster, and probably safer 
considering people's data is important).
2. Or...it can be done by deleting the childrens as well.  Some people might 
prefer that...because suppose they mark the parent as completed, and want to 
purge everything below it as well?

I have attached a patch for both...against the release candidate 3's 
kotodoview.cpp file.

Anyways, sorry if you already fixed this...I don't know what you guys are up 
to, and I'd like to see where else I could help here :-)  This is the first 
time I ever reported anything to KDE.  If you want it done a different way, 
let me know, I'll see what I can do.

Tim Vail
["difftodoview" (text/x-diff)]

*** kdepim-3.0rc3/korganizer/kotodoview.cpp	Thu Mar  7 20:18:55 2002
--- kdepimbk/korganizer/kotodoview.cpp	Mon Apr  1 03:48:00 2002
***************
*** 479,487 ****
--- 479,500 ----
    if (result == KMessageBox::Continue) {
      QPtrList<Todo> todoCal = calendar()->getTodoList();
  
+     QPtrList<Todo> completed;
      Todo *aTodo;
+     QMap< Incidence *, Incidence * > parents;
      for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) {
      if (aTodo->isCompleted())
+       completed.append(aTodo);
+     else {
+       Incidence * relate = aTodo -> relatedTo();
+       while( relate ) {
+ 	parents.insert( relate, aTodo, false );
+ 	relate = relate -> relatedTo();
+       }
+     }
+     }
+     for( aTodo = completed.first(); aTodo; aTodo = completed.next()) {
+     if(!parents.contains(aTodo))
        calendar()->deleteTodo(aTodo);
      }
      updateView();

["otherdiff" (text/x-diff)]

--- kdepim-3.0rc3/korganizer/kotodoview.cpp	Thu Mar  7 20:18:55 2002
+++ kdepimbk/korganizer/kotodoview.cpp	Mon Apr  1 05:25:28 2002
@@ -26,6 +26,8 @@
 #include <qlayout.h>
 #include <qheader.h>
 #include <qcursor.h>
+#include <qptrdict.h>
+#include <qptrstack.h>
 
 #include <kdebug.h>
 #include <klocale.h>
@@ -476,13 +478,41 @@
   int result = KMessageBox::warningContinueCancel(this,
       i18n("Delete all completed To-Dos?"),i18n("Purge To-Dos"),i18n("Purge"));
 
+  // Keep on trying until all of the completed items are deleted.
   if (result == KMessageBox::Continue) {
     QPtrList<Todo> todoCal = calendar()->getTodoList();
 
+    QPtrList<Todo> completed;
     Todo *aTodo;
+    // Map the parents to the incomplete todos.
+    QPtrDict<Todo> parents;
     for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) {
-    if (aTodo->isCompleted())
-      calendar()->deleteTodo(aTodo);
+      if (aTodo->isCompleted())
+        completed.append(aTodo);
+      else {
+        Incidence * relate = aTodo -> relatedTo();
+        if( relate ) {
+	  parents.insert( relate, aTodo );
+        }
+      }
+    }
+    Todo * child;
+    QPtrStack<Todo> toDelete;
+    for( aTodo = completed.first(); aTodo; aTodo = completed.next()) {
+      // Need to recursively delete all the children.
+      toDelete.push(aTodo);
+      while( !toDelete.isEmpty() ) {
+	aTodo = toDelete.pop();
+	child = parents[aTodo];
+	// Find all the children, and push them on stack.  They will be deleted
+	// later.
+	while( child ) {
+	    toDelete.push(child);
+	    parents.remove( aTodo );
+	    child = parents[aTodo];
+	}
+	calendar()->deleteTodo(aTodo);
+      }
     }
     updateView();
   }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic