- Removed all obsolete hooks, except from commands.cpp, which is being
  worked on in parallel.
- Implemented new on-launch and on-exit unit tests.
This commit is contained in:
Paul Beckingham 2011-04-17 21:09:58 -04:00
parent 2f4efb28d6
commit 48eb4757f8
15 changed files with 2816 additions and 3246 deletions

View file

@ -341,25 +341,21 @@ void TDB::location (const std::string& path)
////////////////////////////////////////////////////////////////////////////////
void TDB::lock (bool lockFile /* = true */)
{
if (context.hooks.trigger ("pre-file-lock"))
mLock = lockFile;
mPending.clear ();
mNew.clear ();
mCompleted.clear ();
mModified.clear ();
foreach (location, mLocations)
{
mLock = lockFile;
mPending.clear ();
mNew.clear ();
mCompleted.clear ();
mModified.clear ();
foreach (location, mLocations)
{
location->pending = openAndLock (location->path + "/pending.data");
location->completed = openAndLock (location->path + "/completed.data");
location->undo = openAndLock (location->path + "/undo.data");
}
mAllOpenAndLocked = true;
context.hooks.trigger ("post-file-lock");
location->pending = openAndLock (location->path + "/pending.data");
location->completed = openAndLock (location->path + "/completed.data");
location->undo = openAndLock (location->path + "/undo.data");
}
mAllOpenAndLocked = true;
}
////////////////////////////////////////////////////////////////////////////////
@ -642,7 +638,6 @@ void TDB::update (const Task& task)
int TDB::commit ()
{
Timer t ("TDB::commit");
context.hooks.trigger ("pre-commit");
int quantity = mNew.size () + mModified.size ();
@ -662,7 +657,6 @@ int TDB::commit ()
writeUndo (*task, mLocations[0].undo);
mNew.clear ();
context.hooks.trigger ("post-commit");
return quantity;
}
@ -729,7 +723,6 @@ int TDB::commit ()
mNew.clear ();
}
context.hooks.trigger ("post-commit");
return quantity;
}
@ -863,7 +856,6 @@ int TDB::nextId ()
////////////////////////////////////////////////////////////////////////////////
void TDB::undo ()
{
context.hooks.trigger ("pre-undo");
Directory location (context.config.get ("data.location"));
std::string undoFile = location.data + "/undo.data";
@ -1147,7 +1139,6 @@ void TDB::undo ()
!confirm ("The undo command is not reversible. Are you sure you want to revert to the previous state?"))
{
std::cout << "No changes made.\n";
context.hooks.trigger ("post-undo");
return;
}
@ -1185,7 +1176,6 @@ void TDB::undo ()
// Rewrite files.
File::write (pendingFile, p);
File::write (undoFile, u);
context.hooks.trigger ("post-undo");
return;
}
}
@ -1224,7 +1214,6 @@ void TDB::undo ()
}
std::cout << "Undo complete.\n";
context.hooks.trigger ("post-undo");
return;
}
}