From 5edf746e07502eb7fed813a1f379f936445765e0 Mon Sep 17 00:00:00 2001 From: Jonas Suhr Christensen Date: Fri, 4 May 2012 14:34:06 +0200 Subject: Fixed task id error when sending update command. --- src/messagehandler.cc | 1 + src/taskmanager.cc | 1 + src/tasktree.cc | 14 +++++++++----- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/messagehandler.cc b/src/messagehandler.cc index 16fe043..0b63da1 100644 --- a/src/messagehandler.cc +++ b/src/messagehandler.cc @@ -101,6 +101,7 @@ MessageList handle_msg(MessageList msgList, clientid_t wsi) { try { task_t t; t.title = m.update.title; + t.id = m.update.id; m.nodes = task_manager.updateTask(m.update.id, t); outmsgs.push_back(m); } diff --git a/src/taskmanager.cc b/src/taskmanager.cc index cf7defc..479299c 100644 --- a/src/taskmanager.cc +++ b/src/taskmanager.cc @@ -129,6 +129,7 @@ TaskIdList TaskManager::createTask(taskid_t parentid) t.title = ""; t.id = id; +// printf("Created node with id %d\n", t.id); try { affectedTasks = tree.insertAsChild(parentid, id, t); } diff --git a/src/tasktree.cc b/src/tasktree.cc index 4d6099e..b91c23b 100644 --- a/src/tasktree.cc +++ b/src/tasktree.cc @@ -68,9 +68,10 @@ TaskIdList TaskTree::insertAsChild(taskid_t parentid, taskid_t id, task_t data) try { node_t* parent = id2node.at(parentid); node_t* child = createNode(id); +// printf("!!!!!!!id in insert: %d\n", data.id); child->data = data; insertChild(parent, child); - + // affectedNodes.push_back(parentid); affectedNodes.push_back(id); TaskIdList ancestors = ancestorList(id); @@ -167,8 +168,10 @@ task_t TaskTree::data(taskid_t id) try { node_t* node = id2node.at(id); - t = node->data; - t.id = node->id; + task_t tmp = node->data; + t.id = tmp.id; + t.title = tmp.title; +// printf("!!!!t.id and tmp.id in data: %d and %d\n", t.id, tmp.id); if(node->parent) t.parentid = node->parent->id; else { if(t.id != rootid) throw std::exception(); @@ -229,10 +232,10 @@ TaskIdList TaskTree::ancestorList(taskid_t id) throw e; } - printf("Collected %d ancestors to %u\n", ancestors.size(), id); +// printf("Collected %d ancestors to %u\n", ancestors.size(), id); for(TaskIdList::iterator it = ancestors.begin(); it != ancestors.end(); it++) { - printf("\tancestor %u\n", *it); +// printf("\tancestor %u\n", *it); } return ancestors; } @@ -246,6 +249,7 @@ node_t* TaskTree::createNode(taskid_t id) { } void TaskTree::insertChild(node_t* parent, node_t* child) { +// printf("!!!!! id when node is inserted %d\n", child->data.id); parent->children.push_back(child); child->parent = parent; } -- cgit v1.2.3