Merge master.
[dcpomatic.git] / src / lib / content.cc
index c4836cfa89a643c1838bc94ef302a99c661d9418..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;
 
@@ -79,7 +80,7 @@ Content::Content (shared_ptr<const Film> f, boost::filesystem::path p)
        _paths.push_back (p);
 }
 
-Content::Content (shared_ptr<const Film> f, shared_ptr<const cxml::Node> node)
+Content::Content (shared_ptr<const Film> f, cxml::ConstNodePtr node)
        : _film (f)
        , _change_signals_frequent (false)
 {
@@ -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()