Merge master.
[dcpomatic.git] / src / lib / content.cc
index b6678cb4d9e7e9555773beb8746754755f0673e9..21e49a2c955ae7e74091ec5c1a43f4e9e238b857 100644 (file)
 #include "ui_signaller.h"
 #include "exceptions.h"
 #include "film.h"
+#include "safe_stringstream.h"
 
 #include "i18n.h"
 
 using std::string;
-using std::stringstream;
 using std::set;
 using std::list;
 using std::cout;
 using std::vector;
+using std::max;
 using boost::shared_ptr;
 using dcp::raw_convert;
 
@@ -215,7 +216,7 @@ Content::technical_summary () const
 DCPTime
 Content::length_after_trim () const
 {
-       return full_length() - trim_start() - trim_end();
+       return max (DCPTime (), full_length() - trim_start() - trim_end());
 }
 
 /** @return string which includes everything about how this content affects
@@ -224,7 +225,7 @@ Content::length_after_trim () const
 string
 Content::identifier () const
 {
-       stringstream s;
+       SafeStringStream s;
        
        s << Content::digest()
          << "_" << position().get()