From 17dfbabb39f19b465d5e609b01d20c4d7fb39b74 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 27 Aug 2011 11:18:43 -0400 Subject: [PATCH] TDB2 & Task - Fixed next_id handling in load_tasks. - Removed unnecessary load in next_id. - Added missing encode call. index 8c0d2e9..3d1b7ce 100644 --- a/src/Task.cpp +++ b/src/Task.cpp @@ -528,7 +528,7 @@ std::string Task::composeF4 () const { ff4 += (first ? "" : " ") + it->first - + ":\"" + json::encode (it->second) + "\""; + + ":\"" + encode (json::encode (it->second)) + "\""; first = false; } } --- src/TDB2.cpp | 11 ++++------- src/Task.cpp | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/TDB2.cpp b/src/TDB2.cpp index a7bd92b0a..6b0447dd5 100644 --- a/src/TDB2.cpp +++ b/src/TDB2.cpp @@ -101,7 +101,7 @@ void TF2::add_task (const Task& task) _added_tasks.push_back (task); // For commit/synch /* - int id = next_id (); + int id = context.tdb2.next_id (); _I2U[id] = task.get ("uuid"); _U2I[task.get ("uuid")] = id; */ @@ -233,7 +233,6 @@ void TF2::load_tasks () if (! _loaded_lines) load_lines (); - int id = 1; int line_number = 0; try { @@ -247,7 +246,9 @@ void TF2::load_tasks () Task::status status = task.getStatus (); if (status != Task::deleted && status != Task::completed) - task.id = id++; + { + task.id = context.tdb2.next_id (); + } _tasks.push_back (task); @@ -548,10 +549,6 @@ int TDB2::gc () // Next ID is that of the last pending task plus one. int TDB2::next_id () { - if (! pending._loaded_tasks) - pending.load_tasks (); - - _id = pending._tasks.back ().id + 1; return _id++; } diff --git a/src/Task.cpp b/src/Task.cpp index 8c0d2e906..3d1b7cee6 100644 --- a/src/Task.cpp +++ b/src/Task.cpp @@ -528,7 +528,7 @@ std::string Task::composeF4 () const { ff4 += (first ? "" : " ") + it->first - + ":\"" + json::encode (it->second) + "\""; + + ":\"" + encode (json::encode (it->second)) + "\""; first = false; } }