mirror of
https://gitlab.com/mbunkus/mkvtoolnix.git
synced 2024-12-29 14:27:42 +00:00
Display an error if the user tries to save chapters that contain editions without a single chapter entry. Allow saving empty chapters to a Matroska file by removing all chapters contained in the file.
Fixes for bug 422.
This commit is contained in:
parent
bdcda42e70
commit
bb72b68865
@ -1,3 +1,11 @@
|
||||
2009-07-06 Moritz Bunkus <moritz@bunkus.org>
|
||||
|
||||
* mmg: bug fix: Trying to save chapters that contain editions
|
||||
without a single chapter entry does no longer result in a crash
|
||||
but a descriptive error message instead. Saving empty chapters to
|
||||
a Matroska file will remove all chapters contained in the file
|
||||
instead of not doing anything. Fixes for bug 422.
|
||||
|
||||
2009-07-05 Moritz Bunkus <moritz@bunkus.org>
|
||||
|
||||
* mkvinfo: enhancement: Implemented speed-ups of up to 50% for
|
||||
|
@ -310,6 +310,23 @@ kax_analyzer_c::update_element(EbmlElement *e,
|
||||
return uer_success;
|
||||
}
|
||||
|
||||
kax_analyzer_c::update_element_result_e
|
||||
kax_analyzer_c::remove_elements(EbmlId id) {
|
||||
try {
|
||||
call_and_validate({}, "remove_elements_0");
|
||||
call_and_validate(overwrite_all_instances(id), "remove_elements_1");
|
||||
call_and_validate(merge_void_elements(), "remove_elements_2");
|
||||
call_and_validate(remove_from_meta_seeks(id), "remove_elements_3");
|
||||
call_and_validate(merge_void_elements(), "remove_elements_4");
|
||||
|
||||
} catch (kax_analyzer_c::update_element_result_e result) {
|
||||
debug_dump_elements_maybe("update_element_exception");
|
||||
return result;
|
||||
}
|
||||
|
||||
return uer_success;
|
||||
}
|
||||
|
||||
/** \brief Sets the m_segment size to the length of the m_file
|
||||
*/
|
||||
void
|
||||
|
@ -85,6 +85,7 @@ public:
|
||||
virtual ~kax_analyzer_c();
|
||||
|
||||
virtual update_element_result_e update_element(EbmlElement *e, bool write_defaults = false);
|
||||
virtual update_element_result_e remove_elements(EbmlId id);
|
||||
virtual EbmlMaster *read_all(const EbmlCallbacks &callbacks);
|
||||
|
||||
virtual EbmlElement *read_element(kax_analyzer_data_c *element_data);
|
||||
|
@ -600,7 +600,7 @@ tab_chapters::on_save_chapters(wxCommandEvent &evt) {
|
||||
return;
|
||||
|
||||
if (source_is_kax_file) {
|
||||
display_update_element_result(analyzer->update_element(chapters));
|
||||
write_chapters_to_matroska_file();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -641,7 +641,7 @@ tab_chapters::on_save_chapters_to_kax_file(wxCommandEvent &evt) {
|
||||
return;
|
||||
}
|
||||
|
||||
display_update_element_result(analyzer->update_element(chapters));
|
||||
write_chapters_to_matroska_file();
|
||||
mdlg->set_last_chapters_in_menu(file_name);
|
||||
}
|
||||
|
||||
@ -776,27 +776,43 @@ tab_chapters::verify_atom_recursively(EbmlElement *e) {
|
||||
|
||||
bool
|
||||
tab_chapters::verify(bool called_interactively) {
|
||||
KaxEditionEntry *eentry;
|
||||
uint32_t eidx, cidx;
|
||||
|
||||
if ((NULL == chapters) || (chapters->ListSize() == 0)) {
|
||||
if (called_interactively)
|
||||
wxMessageBox(Z("No chapter entries have been create yet."), Z("Chapter verification error"), wxCENTER | wxOK | wxICON_ERROR);
|
||||
if (NULL == chapters){
|
||||
wxMessageBox(Z("No chapter entries have been create yet."), Z("Chapter verification error"), wxCENTER | wxOK | wxICON_ERROR);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (0 == chapters->ListSize())
|
||||
return true;
|
||||
|
||||
wxTreeItemId id = tc_chapters->GetSelection();
|
||||
if (id.IsOk())
|
||||
copy_values(id);
|
||||
|
||||
for (eidx = 0; eidx < chapters->ListSize(); eidx++) {
|
||||
KaxEditionEntry *eentry = static_cast<KaxEditionEntry *>((*chapters)[eidx]);
|
||||
bool contains_atom = false;
|
||||
|
||||
for (cidx = 0; cidx < eentry->ListSize(); cidx++)
|
||||
if (dynamic_cast<KaxChapterAtom *>((*eentry)[cidx]) != NULL) {
|
||||
contains_atom = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!contains_atom) {
|
||||
wxMessageBox(Z("Each edition must contain at least one chapter."), Z("Chapter verification error"), wxCENTER | wxOK | wxICON_ERROR);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
fix_mandatory_chapter_elements(chapters);
|
||||
|
||||
for (eidx = 0; eidx < chapters->ListSize(); eidx++) {
|
||||
eentry = static_cast<KaxEditionEntry *>((*chapters)[eidx]);
|
||||
for (cidx = 0; cidx < eentry->ListSize(); cidx++) {
|
||||
KaxEditionEntry *eentry = static_cast<KaxEditionEntry *>((*chapters)[eidx]);
|
||||
for (cidx = 0; cidx < eentry->ListSize(); cidx++)
|
||||
if ((dynamic_cast<KaxChapterAtom *>((*eentry)[cidx]) != NULL) && !verify_atom_recursively((*eentry)[cidx]))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!chapters->CheckMandatory())
|
||||
@ -1859,7 +1875,9 @@ tab_chapters::is_empty() {
|
||||
}
|
||||
|
||||
void
|
||||
tab_chapters::display_update_element_result(kax_analyzer_c::update_element_result_e result) {
|
||||
tab_chapters::write_chapters_to_matroska_file() {
|
||||
kax_analyzer_c::update_element_result_e result = (0 == chapters->ListSize() ? analyzer->remove_elements(KaxChapters::ClassInfos.GlobalId) : analyzer->update_element(chapters));
|
||||
|
||||
switch (result) {
|
||||
case kax_analyzer_c::uer_success:
|
||||
mdlg->set_status_bar(Z("Chapters written."));
|
||||
|
@ -119,7 +119,7 @@ public:
|
||||
bool is_empty();
|
||||
|
||||
protected:
|
||||
void display_update_element_result(kax_analyzer_c::update_element_result_e result);
|
||||
void write_chapters_to_matroska_file();
|
||||
};
|
||||
|
||||
#endif // __TAB_CHAPTERS_H
|
||||
|
Loading…
Reference in New Issue
Block a user