- 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

@@ -191,25 +191,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;
}
////////////////////////////////////////////////////////////////////////////////
@@ -492,7 +488,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 ();
@@ -512,7 +507,6 @@ int TDB::commit ()
writeUndo (*task, mLocations[0].undo);
mNew.clear ();
context.hooks.trigger ("post-commit");
return quantity;
}
@@ -579,7 +573,6 @@ int TDB::commit ()
mNew.clear ();
}
context.hooks.trigger ("post-commit");
return quantity;
}
@@ -713,7 +706,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";
@@ -997,7 +989,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;
}
@@ -1035,7 +1026,6 @@ void TDB::undo ()
// Rewrite files.
File::write (pendingFile, p);
File::write (undoFile, u);
context.hooks.trigger ("post-undo");
return;
}
}
@@ -1074,7 +1064,6 @@ void TDB::undo ()
}
std::cout << "Undo complete.\n";
context.hooks.trigger ("post-undo");
return;
}
}