Filter: Corrected implementation of ::safety

This commit is contained in:
Paul Beckingham 2015-06-27 21:08:24 -04:00
parent e0291d35e4
commit 358223a6b1
2 changed files with 11 additions and 14 deletions

View file

@ -182,7 +182,7 @@ void Filter::subset (std::vector <Task>& output, bool applyContext /* = true */)
} }
else else
{ {
safety (precompiled.size ()); safety ();
context.timer_filter.stop (); context.timer_filter.stop ();
for (auto& task : context.tdb2.pending.get_tasks ()) for (auto& task : context.tdb2.pending.get_tasks ())
@ -261,15 +261,13 @@ bool Filter::pendingOnly ()
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Disaster avoidance mechanism. If a WRITECMD has no filter, then it can cause // Disaster avoidance mechanism. If a WRITECMD has no filter, then it can cause
// all tasks to be modified. This is usually not intended. // all tasks to be modified. This is usually not intended.
void Filter::safety (unsigned int terms) void Filter::safety ()
{ {
for (auto& a : context.cli2._args) for (auto& a : context.cli2._args)
{ {
if (a.hasTag ("CMD")) if (a.hasTag ("CMD"))
{ {
if (a.hasTag ("WRITECMD")) if (a.hasTag ("WRITECMD"))
{
if (terms)
{ {
if (! context.config.getBoolean ("allow.empty.filter")) if (! context.config.getBoolean ("allow.empty.filter"))
throw std::string (STRING_TASK_SAFETY_ALLOW); throw std::string (STRING_TASK_SAFETY_ALLOW);
@ -282,7 +280,6 @@ void Filter::safety (unsigned int terms)
// Sounds the alarm. // Sounds the alarm.
throw std::string (STRING_TASK_SAFETY_FAIL); throw std::string (STRING_TASK_SAFETY_FAIL);
} }
}
// CMD was found. // CMD was found.
return; return;

View file

@ -43,7 +43,7 @@ public:
void subset (const std::vector <Task>&, std::vector <Task>&, bool applyContext = true); void subset (const std::vector <Task>&, std::vector <Task>&, bool applyContext = true);
void subset (std::vector <Task>&, bool applyContext = true); void subset (std::vector <Task>&, bool applyContext = true);
bool pendingOnly (); bool pendingOnly ();
void safety (unsigned int); void safety ();
private: private:
int _startCount; int _startCount;