diff -ru progect.orig/ToDoDB.c progect/ToDoDB.c
--- progect.orig/ToDoDB.c	Mon Jan 26 17:38:02 2004
+++ progect/ToDoDB.c	Wed Dec 27 07:36:32 2006
@@ -760,7 +760,7 @@
 Err ToDoChangeRecord(DmOpenRef dbP, UInt16 *index, 
 	ToDoRecordFieldType changedField, void * data)
 {
-	Err 						err;
+	Err 						err = 0;
 	Int16 					cLen;
 	UInt16					attr;
 	UInt16 					curSize;
@@ -776,7 +776,7 @@
 	SortRecordInfoType	sortInfo;
 	
 	// Get the record which we are going to change
-	recordH = DmQueryRecord(dbP, *index);
+	recordH = DmGetRecord(dbP, *index);
 	src = MemHandleLock (recordH);
 	
 
@@ -868,7 +868,7 @@
 			{
 			MemPtrUnlock (src);
 			err = MemHandleResize (recordH, newSize);
-			if (err) return (err);
+			if (err) goto exit;
 			src = MemHandleLock (recordH);
 			}
 		
@@ -897,7 +897,7 @@
 		offset = sizeof(DateType) + 1 + StrLen((Char *)&src->description) + 1;
 		MemPtrUnlock (src);
 		err = MemHandleResize (recordH, newSize);
-		if (err) return (err);
+		if (err) goto exit;
 
 		src = MemHandleLock (recordH);
 		DmStrCopy (src, offset, data);
@@ -905,13 +905,15 @@
 		}
 
 exit:
-	MemPtrUnlock (src);
+	if (!err)
+		MemPtrUnlock (src);
+	DmReleaseRecord(dbP, *index, true);
 
 #if ERROR_CHECK_LEVEL == ERROR_CHECK_FULL
 	//ECToDoDBValidate (dbP);
 #endif
 
-	return 0;
+	return err;
 }
 
 
diff -ru progect.orig/link.c progect/link.c
--- progect.orig/link.c	Thu Dec 11 21:35:15 2003
+++ progect/link.c	Wed Dec 27 05:38:35 2006
@@ -51,7 +51,7 @@
 {
 	if (CheckLinkMaster())
 	{
-		Char* desc = TaskGetDescription(dbP, index);
+		Char* desc = TaskGetDescription(dbP, index, false);
 		LinkSimpleType* p = LinkSimpleNew(dbP, index, desc);
 		MemPtrFree(desc);
 
@@ -216,7 +216,7 @@
 		}
 
 		level = TaskGetLevel(dbP, i) - 1;
-		desc = TaskGetDescription(dbP, i);
+		desc = TaskGetDescription(dbP, i, false);
 		cnt += StrLen(desc) + level;
 
 		// control the length
diff -ru progect.orig/progect.c progect/progect.c
--- progect.orig/progect.c	Sat Apr 10 22:11:03 2004
+++ progect/progect.c	Wed Dec 27 06:40:19 2006
@@ -2401,7 +2401,7 @@
 				// show the up button
 				CtlShowControl(GetObjectPtr(Btn_Sub_Up));
 				// update the titlebar
-				p = TaskGetDescription(gdbP, gParentTask);
+				p = TaskGetDescription(gdbP, gParentTask, false);
 				SetFormTitle(frm, p);
 				MemPtrFree(p);
 				if (TaskGetHasChild(gdbP, gParentTask))
@@ -2438,7 +2438,7 @@
 			}
 			else
 			{
-				char* p = TaskGetDescription(gdbP, gParentTask);
+				Char* p = TaskGetDescription(gdbP, gParentTask, false);
 				SetFormTitle(frm, p);
 				MemPtrFree(p);
 			}
@@ -2691,7 +2691,7 @@
 			// show the up button
 			CtlShowControl(GetObjectPtr(Btn_Sub_Up));
 			// update the titlebar
-			p = TaskGetDescription(gdbP, gParentTask);
+			p = TaskGetDescription(gdbP, gParentTask, false);
 			// uh oh, sanity check failed, try to reset to defaults
 			if (!p)
 			{
diff -ru progect.orig/progect_beam.c progect/progect_beam.c
--- progect.orig/progect_beam.c	Sun Dec  2 10:27:08 2001
+++ progect/progect_beam.c	Wed Dec 27 05:39:53 2006
@@ -2279,7 +2279,7 @@
 					if (gSavedPrefs.deleteWarn)
 					{
 						// get the description for the warning
-						char* desc = TaskGetDescription(gdbP, gActualTask);
+						char* desc = TaskGetDescription(gdbP, gActualTask, false);
 						if (FrmCustomAlert(AltConfirmDelete, desc, " ", " ") != 0)
 							deleteOK = false;
 						MemPtrFree(desc);
@@ -2541,7 +2541,7 @@
 				// show the up button
 				CtlShowControl(GetObjectPtr(Btn_Sub_Up));
 				// update the titlebar
-				p = TaskGetDescription(gdbP, gParentTask);
+				p = TaskGetDescription(gdbP, gParentTask, false);
 				SetFormTitle(frm, p);
 				MemPtrFree(p);
 				if (TaskGetHasChild(gdbP, gParentTask))
@@ -2578,7 +2578,7 @@
 			}
 			else
 			{
-				char* p = TaskGetDescription(gdbP, gParentTask);
+				Char* p = TaskGetDescription(gdbP, gParentTask, false);
 				SetFormTitle(frm, p);
 				MemPtrFree(p);
 			}
@@ -2826,7 +2826,7 @@
 			// show the up button
 			CtlShowControl(GetObjectPtr(Btn_Sub_Up));
 			// update the titlebar
-			p = TaskGetDescription(gdbP, gParentTask);
+			p = TaskGetDescription(gdbP, gParentTask, false);
 			SetFormTitle(frm, p);
 			MemPtrFree(p);
 			if (TaskGetHasChild(gdbP, gParentTask))
diff -ru progect.orig/task.c progect/task.c
--- progect.orig/task.c	Wed Feb  4 22:03:01 2004
+++ progect/task.c	Wed Dec 27 08:19:28 2006
@@ -1141,7 +1141,7 @@
 	noteSize = StrLen(note);
 
 	// TODO : this will crash when trying to add a note to a direct link
-	desc = TaskGetDescription(dbP, index);
+	desc = TaskGetDescription(dbP, index, false);
 	descSize = StrLen(desc);
 	MemPtrFree(desc);
 	desc=NULL;
@@ -1195,7 +1195,7 @@
 	noteSize = StrLen(TaskGetNote(dbP, index));
 	oldSize = MemHandleSize(h);
 	newDescSize = StrLen(desc);
-	oldDesc = TaskGetDescription(dbP, index);
+	oldDesc = TaskGetDescription(dbP, index, false);
 	oldDescSize = StrLen(oldDesc);
 	MemPtrFree(oldDesc);
 	newSize = oldSize - oldDescSize + newDescSize;
@@ -1289,7 +1289,7 @@
 
 	DBGMSG((DBB, "TaskGetDescriptionEmpty"));
 
-	desc = TaskGetDescription(dbP,index);
+	desc = TaskGetDescription(dbP,index, false);
 	if (*desc)
 		descriptionIsEmpty=false;
 	else
@@ -1298,7 +1298,7 @@
 	MemPtrFree(desc);
 	
 	return descriptionIsEmpty;
-} // Char* TaskGetDescription(DmOpenRef dbP, UInt16 index)
+} // Char* TaskGetDescriptionEmpty(DmOpenRef dbP, UInt16 index)
 
 
 
@@ -1318,7 +1318,7 @@
  *             under POSE)
  *           - support direct linked task.
  ***************************************************************************/
-Char* TaskGetDescription(DmOpenRef dbP, UInt16 index)
+Char* TaskGetDescription(DmOpenRef dbP, UInt16 index, Boolean withParents)
 {
 	char* desc = NULL;
 	MemHandle h = NULL;
@@ -1327,17 +1327,54 @@
 	DBGMSG((DBB, "TaskGetDescription"));
 
 	h = DmQueryRecord(dbP, index);
-	if (h)
+	if (h == NULL)
+		return desc;
+
+	pTask = MemHandleLock(h);
+	if (pTask == NULL)
+		return desc;
+
+	desc = TaskGetDescriptionByTaskPtr(pTask);
+	MemHandleUnlock(h);
+
+	// Huidae Cho <http://geni.ath.cx>, Dec 27, 2006
+	if (withParents) // user wants complete desc ?
 	{
-		pTask = MemHandleLock(h);
-		if (pTask)
+		Char *pdesc;
+		UInt16 pindex = index;
+		UInt8 level = TaskGetLevel(dbP, pindex); // get level for stop condition
+		#define maxDescLen 256
+		Char descWithParents[maxDescLen]; // 256 from ToDoDB.c, maxDescLen
+
+		SafeCopy(descWithParents, desc, maxDescLen);
+		MemPtrFree(desc);
+
+		while (level > 1)
 		{
-			desc = TaskGetDescriptionByTaskPtr(pTask);
-			MemHandleUnlock(h);
+			pindex = TaskGetFatherIndex(dbP, pindex); // get father
+			if (pindex == dmMaxRecordIndex) break; // check validity
+			level = TaskGetLevel(dbP, pindex); // get level for stop condition
+			pdesc = TaskGetDescription(dbP, pindex, false); // get description
+			if (StrLen(pdesc) + StrLen(descWithParents) < maxDescLen - 4) // 0:
+			{
+				StrCat(descWithParents, " | "); // separator
+				StrCat(descWithParents, pdesc);
+				MemPtrFree(pdesc);
+			}
+			else
+			{
+				MemPtrFree(pdesc);
+				break;
+			}
 		}
+
+		desc = MemPtrNew(StrLen(descWithParents) + 1);
+		StrCopy(desc, descWithParents);
 	}
+	// end of Huidae Cho
+
 	return desc;
-} // Char* TaskGetDescription(DmOpenRef dbP, UInt16 index)
+} // Char* TaskGetDescription(DmOpenRef dbP, UInt16 index, Boolean withParents)
 
 
 
@@ -2306,15 +2343,14 @@
 	DmOpenRef ToDoDB;
 	ToDoItemType task;
 	MemHandle h;
-	TaskExtendedRecordType *p, *parent;
+	TaskExtendedRecordType *p;
 	UInt16 todoIndex = 0;
 	Err err = errNone;
 	UInt32 uniqueID;
 	TaskFormatType format;
 	Char name[dmCategoryLength];
 	UInt16 category;
-	#define maxDescLen 256
-	Char descWithParents[maxDescLen]; // 256 from ToDoDB.c, maxDescLen
+	Char *desc = NULL;
 
 	DBGMSG((DBB, "TaskPublishToDo"));
 
@@ -2350,34 +2386,8 @@
 
 	if (1) // user wants complete desc ?
 	{
-		Char *pdesc;
-		UInt16 pindex = index;
-		UInt8 level = 2;
-		parent = p;
-		SafeCopy(descWithParents, &StdFields(p)->description,maxDescLen);
-		while (level > 1)
-		{
-			pindex = TaskGetFatherIndex(dbP, pindex); // get father
-			if (pindex == dmMaxRecordIndex) break; // check validity
-			level = TaskGetLevel(dbP, pindex); // get level for stop condition
-			pdesc = TaskGetDescription(dbP, pindex); // get description
-			if (StrLen(pdesc) + StrLen(descWithParents) < maxDescLen - 4) // 0:
-			{
-				StrCat(descWithParents, " | "); // separator
-				StrCat(descWithParents, pdesc);
-				MemPtrFree(pdesc);
-			}
-			else
-			{
-				MemPtrFree(pdesc);
-				break;
-			}
-		}
-	}
-
-	if (1) // complete desc
-	{
-		task.description = descWithParents;
+		desc = TaskGetDescription(dbP, index, true); // get description
+		task.description = desc;
 	}
 	else
 	{
@@ -2407,6 +2417,9 @@
 	// create the ToDo entry
 	err = ToDoNewRecord(ToDoDB, &task, category, &todoIndex);
 
+	if (desc != NULL)
+		MemPtrFree(desc);
+
 	// Unlock the task, now that the ToDo is created
 	MemHandleUnlock(h);
 
@@ -2581,33 +2594,75 @@
 	// see if we're synchronized with a ToDo
 	if (TaskGetFormat(dbP, index).hasToDo)
 	{
+		// Huidae Cho <http://geni.ath.cx>, Dec 27, 2006
+		// speed up
 		Err err;
-		// check the status in ToDo and update this task
-		err = TaskSetToDoStatus(dbP, index, toDoComplete,
-			TaskGetCompleted(dbP, index),
-			0, gNoDate, 0, NULL);
-		err = TaskSetToDoStatus(dbP, index, toDoDueDate,
-			0, 0,
-			TaskGetDueDate(dbP, index),
-			0, NULL);
-		err = TaskSetToDoStatus(dbP, index, toDoPriority,
-			0,
-			TaskGetPriority(dbP, index),
-			gNoDate, 0, NULL);
-		err = TaskSetToDoStatus(dbP, index, toDoCategory,
-			0, 0, gNoDate,
-			TaskGetCategory(dbP, index), NULL);
-		string = TaskGetDescription(dbP, index);
-		err = TaskSetToDoStatus(dbP, index, toDoDescription,
-			0,
-			0, gNoDate, 0, string);
+		DmOpenRef ToDoDB;
+		UInt32 uniqueID;
+		UInt16 todoIndex;
+		UInt16 zero = 0, one = 1;
+		Char name[dmCategoryLength];
+
+		UInt8 value = TaskGetCompleted(dbP, index);
+		UInt16 priority = TaskGetPriority(dbP, index);
+		DateType dueDate = TaskGetDueDate(dbP, index);
+		UInt16 category = TaskGetCategory(dbP, index);
+
+		uniqueID = TaskGetToDoUniqueID(dbP, index);
+
+		if (!uniqueID)
+			return pgError;
+
+		// try to open the ToDo database
+		if (ToDoGetDatabase(&ToDoDB, dmModeReadWrite))
+		{
+			FrmCustomAlert(AltEmpty, "Can't open the todo database", " ", " ");
+			return pgError;
+		}
+
+		if (DmFindRecordByID(ToDoDB, uniqueID, &todoIndex))
+		{
+			DmCloseDatabase(ToDoDB);
+			DEBUG1("The corresponding ToDo was not found, removing link.");
+			TaskRemoveHasToDo(dbP, index);
+			return pgError;
+		}
+
+		err = ToDoChangeRecord(ToDoDB, &todoIndex, toDoComplete, 
+			value == ACTION_DONE ? &one : &zero );
+
+		if (priority > 5 || priority < 1)
+			priority = 5;
+		err = ToDoChangeRecord(ToDoDB, &todoIndex, toDoPriority, 
+				&priority);
+
+		if (dueDate.month == 0)
+			*((UInt16 *) &dueDate) = toDoNoDueDate;
+		err = ToDoChangeRecord(ToDoDB, &todoIndex, toDoDueDate, 
+			(UInt16*)&dueDate);
+
+		CategoryGetName(dbP, category, name);
+		category = CategoryFind(ToDoDB, name);
+		// Task category not in ToDo - set ToDo category to Unfiled
+		if (category == dmAllCategories)
+		{
+			category = 0;
+		}
+		err = ToDoChangeRecord(ToDoDB, &todoIndex, toDoCategory, 
+							   &category);
+
+		string = TaskGetDescription(dbP, index, true);
+		err = ToDoChangeRecord(ToDoDB, &todoIndex, toDoDescription,
+				string);
 		MemPtrFree(string);
+
 		string = TaskGetNote(dbP, index);
-		err = TaskSetToDoStatus(dbP, index, toDoNote,
-			0,
-			0, gNoDate, 0, string);
+		err = ToDoChangeRecord(ToDoDB, &todoIndex, toDoNote, string);
 // +++ FIX THIS +++ Note frees the string before it returns, very, very bad...
 //		MemPtrFree(string);
+
+		DmCloseDatabase(ToDoDB);
+		// end of Huidae Cho
 	}
 	return err;
 } // Err TaskUpdateToDo(DmOpenRef dbP, UInt16 index)
@@ -2845,8 +2900,48 @@
 
 	if (description)
 	{
-		*description = MemPtrNew(StrLen(&(p->description)) + 1);
-		StrCopy(*description,&(p->description));
+		// Huidae Cho <http://geni.ath.cx>, Dec 27, 2006
+		// strip out " | parent..." from ToDo description
+		#define maxDescLen 256
+		Char descParents[maxDescLen]; // 256 from ToDoDB.c, maxDescLen
+		UInt16 pindex = index;
+
+		descParents[0] = chrNull;
+
+		pindex = TaskGetFatherIndex(dbP, pindex); // get father
+		if (pindex != dmMaxRecordIndex)
+		{
+			Char *desc = TaskGetDescription(dbP, pindex, true);
+			StrCopy(descParents, " | ");
+			StrCat(descParents, desc);
+			MemPtrFree(desc);
+		}
+
+		if (descParents[0] == chrNull)
+		{
+			// original
+			*description = MemPtrNew(StrLen(&(p->description)) + 1);
+			StrCopy(*description,&(p->description));
+			// end of original
+		}
+		else
+		{
+			Char *ptr = StrStr(&(p->description), descParents);
+			if (ptr != NULL && ptr[StrLen(descParents)] == chrNull)
+			{
+				Int16 n = StrLen(&(p->description)) - StrLen(descParents);
+
+				*description = MemPtrNew(n + 1);
+				StrNCopy(*description, &(p->description), n);
+				(*description)[n] = chrNull;
+			}
+			else
+			{
+				*description = MemPtrNew(StrLen(&(p->description)) + 1);
+				StrCopy(*description,&(p->description));
+			}
+		}
+		// end of Huidae Cho
 	}
 
 	if (note)
@@ -3185,7 +3280,7 @@
 		if (gSavedPrefs.deleteWarn)
 		{
 			// get the description for the warning
-			char* desc = TaskGetDescription(dbP, taskToDelete);
+			char* desc = TaskGetDescription(dbP, taskToDelete, false);
 			if (FrmCustomAlert(AltConfirmDelete, desc, " ", " ") != 0)
 				deleteOK = false;
 			MemPtrFree(desc);
diff -ru progect.orig/task.h progect/task.h
--- progect.orig/task.h	Wed Feb  4 22:03:01 2004
+++ progect/task.h	Wed Dec 27 07:35:22 2006
@@ -99,7 +99,7 @@
 	TASKSECT;
 Char*    TaskGetNote(DmOpenRef dbP, UInt16 index) 
 	TASKSECT;
-Char* TaskGetDescription(DmOpenRef dbP, UInt16 index)
+Char* TaskGetDescription(DmOpenRef dbP, UInt16 index, Boolean withParents)
 	TASKSECT;
 Char* TaskGetDescriptionByTaskPtr(TaskExtendedRecordType* pTask)
 	TASKSECT;
