mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
Datafile: Added assert to ::deleteInterval to confirm redundancy
This commit is contained in:
parent
32e066a388
commit
d601a77c42
1 changed files with 10 additions and 12 deletions
|
@ -105,20 +105,18 @@ void Datafile::addInterval (const Interval& interval)
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void Datafile::deleteInterval (const Interval& interval)
|
void Datafile::deleteInterval (const Interval& interval)
|
||||||
{
|
{
|
||||||
// Return false if the interval does not belong in this file.
|
|
||||||
// Note: end date might be zero.
|
// Note: end date might be zero.
|
||||||
if (_range.overlap (interval.range))
|
assert (_range.overlap (interval.range));
|
||||||
{
|
|
||||||
if (! _lines_loaded)
|
|
||||||
load_lines ();
|
|
||||||
|
|
||||||
auto serialized = interval.serialize ();
|
if (! _lines_loaded)
|
||||||
auto i = std::find (_lines.begin (), _lines.end (), serialized);
|
load_lines ();
|
||||||
if (i != _lines.end ())
|
|
||||||
{
|
auto serialized = interval.serialize ();
|
||||||
_lines.erase (i);
|
auto i = std::find (_lines.begin (), _lines.end (), serialized);
|
||||||
_dirty = true;
|
if (i != _lines.end ())
|
||||||
}
|
{
|
||||||
|
_lines.erase (i);
|
||||||
|
_dirty = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue