static void write_changes(options_cptr &options, kax_analyzer_c *analyzer) { std::vector<EbmlId> ids_to_write; ids_to_write.push_back(KaxInfo::ClassInfos.GlobalId); ids_to_write.push_back(KaxTracks::ClassInfos.GlobalId); ids_to_write.push_back(KaxTags::ClassInfos.GlobalId); ids_to_write.push_back(KaxChapters::ClassInfos.GlobalId); ids_to_write.push_back(KaxAttachments::ClassInfos.GlobalId); for (auto &id_to_write : ids_to_write) { for (auto &target : options->m_targets) { if (!target->get_level1_element()) continue; EbmlMaster &l1_element = *target->get_level1_element(); if (id_to_write != l1_element.Generic().GlobalId) continue; mxverb(2, boost::format(Y("Element %1% is written.\n")) % l1_element.Generic().DebugName); kax_analyzer_c::update_element_result_e result = l1_element.ListSize() ? analyzer->update_element(&l1_element, true) : analyzer->remove_elements(EbmlId(l1_element)); if (kax_analyzer_c::uer_success != result) display_update_element_result(l1_element.Generic(), result); break; } } }
void header_editor_frame_c::on_file_save(wxCommandEvent &) { wxDateTime curr_mtime; m_file_name.GetTimes(NULL, &curr_mtime, NULL); if (curr_mtime != m_file_mtime) { wxMessageBox(Z("The file has been changed by another program since it was read by the header editor. Therefore you have to re-load it. " "Unfortunately this means that all of your changes will be lost."), Z("File modified"), wxOK | wxICON_ERROR, this); return; } if (!have_been_modified()) { wxMessageBox(Z("None of the header fields has been modified. Nothing has been saved."), Z("No fields modified"), wxOK | wxICON_INFORMATION, this); return; } wxTreeItemId page_id = validate_pages(); if (page_id.IsOk()) { m_tc_tree->SelectItem(page_id); wxMessageBox(Z("There were errors in the header values preventing the headers from being saved. The first error has been selected."), Z("Header validation"), wxOK | wxICON_ERROR, this); return; } do_modifications(); size_t i; bool tracks_written = false; for (i = 0; m_top_level_pages.size() > i; ++i) { if (m_top_level_pages[i]->has_been_modified()) { if (m_top_level_pages[i]->m_l1_element->Generic().GlobalId == KaxTracks::ClassInfos.GlobalId) { if (tracks_written) continue; tracks_written = true; } kax_analyzer_c::update_element_result_e result = m_analyzer->update_element(m_top_level_pages[i]->m_l1_element, true); if (kax_analyzer_c::uer_success != result) display_update_element_result(result); } } open_file(m_file_name); }