diff options
| author | Carl Hetherington <cth@carlh.net> | 2021-02-14 12:36:23 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2021-02-14 21:40:06 +0100 |
| commit | a632e34e3c9ca94574fcab1b3006227ed2833766 (patch) | |
| tree | d8bbfa15962fc466a3ec0173f7ed778e1792a188 /src | |
| parent | 39fce9acb7869c551fded172aa070d75c7a9bc50 (diff) | |
Fix incorrect coalesce() output when one input range is wholly
covered by another.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/dcpomatic_time_coalesce.h | 6 | ||||
| -rw-r--r-- | src/lib/empty.h | 2 |
2 files changed, 5 insertions, 3 deletions
diff --git a/src/lib/dcpomatic_time_coalesce.h b/src/lib/dcpomatic_time_coalesce.h index e6e16641e..56f82bcb6 100644 --- a/src/lib/dcpomatic_time_coalesce.h +++ b/src/lib/dcpomatic_time_coalesce.h @@ -32,11 +32,11 @@ std::list<TimePeriod<T> > coalesce (std::list<TimePeriod<T> > periods) do { coalesced.clear (); did_something = false; - for (typename std::list<TimePeriod<T> >::const_iterator i = periods.begin(); i != periods.end(); ++i) { - typename std::list<TimePeriod<T> >::const_iterator j = i; + for (auto i = periods.begin(); i != periods.end(); ++i) { + auto j = i; ++j; if (j != periods.end() && (i->overlap(*j) || i->to == j->from)) { - coalesced.push_back (TimePeriod<T> (i->from, j->to)); + coalesced.push_back(TimePeriod<T>(std::min(i->from, j->from), std::max(i->to, j->to))); did_something = true; ++i; } else { diff --git a/src/lib/empty.h b/src/lib/empty.h index 2a975562a..443d3322b 100644 --- a/src/lib/empty.h +++ b/src/lib/empty.h @@ -29,6 +29,7 @@ struct empty_test1; struct empty_test2; struct empty_test3; +struct empty_test_with_overlapping_content; struct player_subframe_test; class Empty @@ -51,6 +52,7 @@ private: friend struct ::empty_test1; friend struct ::empty_test2; friend struct ::empty_test3; + friend struct ::empty_test_with_overlapping_content; friend struct ::player_subframe_test; std::list<dcpomatic::DCPTimePeriod> _periods; |
