Sort KDM CPL list in reverse timestamp order (#1496).
[dcpomatic.git] / src / lib / film.cc
index 76cd8da9645f256708dfaee443c0053dde2d797c..f61d5106f14e42c5a60e71d015ed1221d015c152 100644 (file)
@@ -1038,7 +1038,16 @@ Film::j2c_path (int reel, Frame frame, Eyes eyes, bool tmp) const
        return file (p);
 }
 
-/** Find all the DCPs in our directory that can be dcp::DCP::read() and return details of their CPLs */
+static
+bool
+cpl_summary_compare (CPLSummary const & a, CPLSummary const & b)
+{
+       return a.last_write_time > b.last_write_time;
+}
+
+/** Find all the DCPs in our directory that can be dcp::DCP::read() and return details of their CPLs.
+ *  The list will be returned in reverse order of timestamp (i.e. most recent first).
+ */
 vector<CPLSummary>
 Film::cpls () const
 {
@@ -1063,6 +1072,8 @@ Film::cpls () const
                }
        }
 
+       sort (out.begin(), out.end(), cpl_summary_compare);
+
        return out;
 }