mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Bug Fix - recurrence
- Fixed bug whereby handleRecurrence was being called after the tasks were loaded and filtered, and thus handleRecurrence operated on a filtered set, and failed. The fix is to move the call to before the TDB::load call, and to add another TDB::loadPending call inside handleRecurrence. This means TDB::load needs to be reentrant without re-reading the file, and can therefore be called twice, with the likelihood of there being a different filter for each call. This in turn led to the problem whereby handleRecurrence would generate the synthetic tasks, which then sat uncommitted in TDB::mNew. The fix for this is that every call to TDB::loadPending gets the contents of TDB::mNew appended (with correct IDs). This bug is what you might call a good one.
This commit is contained in:
parent
20bd2cf594
commit
8dab95e200
7 changed files with 62 additions and 43 deletions
58
src/TDB.cpp
58
src/TDB.cpp
|
@ -85,6 +85,7 @@ TDB::~TDB ()
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
void TDB::clear ()
|
||||
{
|
||||
mPending.clear ();
|
||||
mLocations.clear ();
|
||||
mLock = true;
|
||||
|
||||
|
@ -196,33 +197,47 @@ int TDB::loadPending (std::vector <Task>& tasks, Filter& filter)
|
|||
|
||||
try
|
||||
{
|
||||
mPending.clear ();
|
||||
|
||||
mId = 1;
|
||||
char line[T_LINE_MAX];
|
||||
foreach (location, mLocations)
|
||||
if (mPending.size () == 0)
|
||||
{
|
||||
line_number = 1;
|
||||
file = location->path + "/pending.data";
|
||||
|
||||
fseek (location->pending, 0, SEEK_SET);
|
||||
while (fgets (line, T_LINE_MAX, location->pending))
|
||||
mId = 1;
|
||||
char line[T_LINE_MAX];
|
||||
foreach (location, mLocations)
|
||||
{
|
||||
int length = ::strlen (line);
|
||||
if (length > 1)
|
||||
line_number = 1;
|
||||
file = location->path + "/pending.data";
|
||||
|
||||
fseek (location->pending, 0, SEEK_SET);
|
||||
while (fgets (line, T_LINE_MAX, location->pending))
|
||||
{
|
||||
// TODO Add hidden attribute indicating source?
|
||||
Task task (line);
|
||||
task.id = mId++;
|
||||
int length = ::strlen (line);
|
||||
if (length > 1)
|
||||
{
|
||||
// TODO Add hidden attribute indicating source?
|
||||
Task task (line);
|
||||
task.id = mId++;
|
||||
|
||||
mPending.push_back (task);
|
||||
if (filter.pass (task))
|
||||
tasks.push_back (task);
|
||||
mPending.push_back (task);
|
||||
}
|
||||
|
||||
++line_number;
|
||||
}
|
||||
|
||||
++line_number;
|
||||
}
|
||||
}
|
||||
|
||||
// Now filter and return.
|
||||
foreach (task, mPending)
|
||||
if (filter.pass (*task))
|
||||
tasks.push_back (*task);
|
||||
|
||||
// Hand back any accumulated additions, if TDB::loadPending is being called
|
||||
// repeatedly.
|
||||
int fakeId = mId;
|
||||
foreach (task, mNew)
|
||||
{
|
||||
task->id = fakeId++;
|
||||
if (filter.pass (*task))
|
||||
tasks.push_back (*task);
|
||||
}
|
||||
}
|
||||
|
||||
catch (std::string& e)
|
||||
|
@ -267,7 +282,7 @@ int TDB::loadCompleted (std::vector <Task>& tasks, Filter& filter)
|
|||
line[length - 1] = '\0';
|
||||
|
||||
Task task (line);
|
||||
task.id = mId++;
|
||||
// Note: no id is set for completed tasks.
|
||||
|
||||
if (filter.pass (task))
|
||||
tasks.push_back (task);
|
||||
|
@ -294,6 +309,7 @@ int TDB::loadCompleted (std::vector <Task>& tasks, Filter& filter)
|
|||
void TDB::add (const Task& task)
|
||||
{
|
||||
mNew.push_back (task);
|
||||
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue