xmlpp::Document doc;
xmlpp::Node* node = doc.create_root_node ("Content");
as_xml (node);
- return content_factory (film, cxml::NodePtr (new cxml::Node (node)), Film::state_version);
+ return content_factory (film, cxml::NodePtr (new cxml::Node (node)), Film::current_state_version);
}
string
{
list<cxml::NodePtr> c = node->node_children ("SubtitleStream");
for (list<cxml::NodePtr>::const_iterator i = c.begin(); i != c.end(); ++i) {
- _subtitle_streams.push_back (shared_ptr<FFmpegSubtitleStream> (new FFmpegSubtitleStream (*i, version)));
+ _subtitle_streams.push_back (shared_ptr<FFmpegSubtitleStream> (new FFmpegSubtitleStream (*i)));
if ((*i)->optional_number_child<int> ("Selected")) {
_subtitle_stream = _subtitle_streams.back ();
}
return a._id != b._id;
}
-FFmpegStream::FFmpegStream (shared_ptr<const cxml::Node> node, int version)
+FFmpegStream::FFmpegStream (shared_ptr<const cxml::Node> node)
: name (node->string_child ("Name"))
, _id (node->number_child<int> ("Id"))
- , _legacy_id (false)
{
- if (version == 4 || node->optional_bool_child ("LegacyId")) {
- _legacy_id = true;
- }
+
}
void
{
root->add_child("Name")->add_child_text (name);
root->add_child("Id")->add_child_text (lexical_cast<string> (_id));
- if (_legacy_id) {
- /* Write this so that version > 4 files are read in correctly
- if the Id came originally from a version <= 4 file.
- */
- root->add_child("LegacyId")->add_child_text ("1");
- }
}
FFmpegAudioStream::FFmpegAudioStream (shared_ptr<const cxml::Node> node, int version)
- : FFmpegStream (node, version)
+ : FFmpegStream (node)
, mapping (node->node_child ("Mapping"), version)
{
frame_rate = node->number_child<int> ("FrameRate");
bool
FFmpegStream::uses_index (AVFormatContext const * fc, int index) const
{
- if (_legacy_id) {
- return _id == index;
- }
-
size_t i = 0;
while (i < fc->nb_streams) {
if (fc->streams[i]->id == _id) {
AVStream *
FFmpegStream::stream (AVFormatContext const * fc) const
{
- if (_legacy_id) {
- if (_id >= int (fc->nb_streams)) {
- return 0;
- }
-
- return fc->streams[_id];
- }
-
size_t i = 0;
while (i < fc->nb_streams) {
if (fc->streams[i]->id == _id) {
* @param t String returned from to_string().
* @param v State file version.
*/
-FFmpegSubtitleStream::FFmpegSubtitleStream (shared_ptr<const cxml::Node> node, int version)
- : FFmpegStream (node, version)
+FFmpegSubtitleStream::FFmpegSubtitleStream (shared_ptr<const cxml::Node> node)
+ : FFmpegStream (node)
{
}
FFmpegStream (std::string n, int i)
: name (n)
, _id (i)
- , _legacy_id (false)
{}
- FFmpegStream (boost::shared_ptr<const cxml::Node>, int);
+ FFmpegStream (boost::shared_ptr<const cxml::Node>);
void as_xml (xmlpp::Node *) const;
private:
int _id;
- /** If this is true, id is in fact the index */
- bool _legacy_id;
};
class FFmpegAudioStream : public FFmpegStream
: FFmpegStream (n, i)
{}
- FFmpegSubtitleStream (boost::shared_ptr<const cxml::Node>, int);
+ FFmpegSubtitleStream (boost::shared_ptr<const cxml::Node>);
void as_xml (xmlpp::Node *) const;
};
* 6 -> 7
* Subtitle offset changed to subtitle y offset, and subtitle x offset added.
*/
-int const Film::state_version = 7;
+int const Film::current_state_version = 7;
/** Construct a Film object in a given directory.
*
, _three_d (false)
, _sequence_video (true)
, _interop (false)
+ , _state_version (current_state_version)
, _dirty (false)
{
set_dci_date_today ();
shared_ptr<xmlpp::Document> doc (new xmlpp::Document);
xmlpp::Element* root = doc->create_root_node ("Metadata");
- root->add_child("Version")->add_child_text (lexical_cast<string> (state_version));
+ root->add_child("Version")->add_child_text (lexical_cast<string> (current_state_version));
root->add_child("Name")->add_child_text (_name);
root->add_child("UseDCIName")->add_child_text (_use_dci_name ? "1" : "0");
cxml::Document f ("Metadata");
f.read_file (file ("metadata.xml"));
- int const version = f.number_child<int> ("Version");
+ _state_version = f.number_child<int> ("Version");
_name = f.string_child ("Name");
_use_dci_name = f.bool_child ("UseDCIName");
_three_d = f.bool_child ("ThreeD");
_interop = f.bool_child ("Interop");
_key = libdcp::Key (f.string_child ("Key"));
- _playlist->set_from_xml (shared_from_this(), f.node_child ("Playlist"), version);
+ _playlist->set_from_xml (shared_from_this(), f.node_child ("Playlist"), _state_version);
_dirty = false;
}
return _key;
}
+ int state_version () const {
+ return _state_version;
+ }
+
/** Identifiers for the parts of our state;
used for signalling changes.
*/
mutable boost::signals2::signal<void (boost::weak_ptr<Content>, int)> ContentChanged;
/** Current version number of the state file */
- static int const state_version;
+ static int const current_state_version;
private:
bool _interop;
libdcp::Key _key;
+ int _state_version;
+
/** true if our state has changed since we last saved it */
mutable bool _dirty;
overall_panel->SetSizer (main_sizer);
}
+ void check_film_state_version (int v)
+ {
+ if (v == 4) {
+ error_dialog (
+ this,
+ _("This film was created with an old version of DVD-o-matic and may not load correctly "
+ "in this version. Please check the film's settings carefully.")
+ );
+ }
+ }
+
private:
void set_film ()
try {
film.reset (new Film (wx_to_std (c->GetPath ())));
film->read_metadata ();
+ check_film_state_version (film->state_version ());
film->log()->set_level (log_level);
set_film ();
} catch (std::exception& e) {
_timer.reset (new wxTimer (this));
_timer->Start (1000);
+ _frame->check_film_state_version (film->state_version ());
+
UpdateChecker::instance()->StateChanged.connect (boost::bind (&App::update_checker_state_changed, this));
if (Config::instance()->check_for_updates ()) {
UpdateChecker::instance()->run ();
}
}
- wxFrame* _frame;
+ Frame* _frame;
shared_ptr<wxTimer> _timer;
};