Don't clear tags until after loading to guard against bad XML file
This commit is contained in:
parent
82014bacd9
commit
4e6d11fe0c
18
src/Tags.cpp
18
src/Tags.cpp
|
@ -1245,24 +1245,26 @@ void TagsEditorDialog::OnLoad(wxCommandEvent & WXUNUSED(event))
|
|||
return;
|
||||
}
|
||||
|
||||
// Remember title and track in case they're read only
|
||||
wxString title = mLocal.GetTag(TAG_TITLE);
|
||||
wxString track = mLocal.GetTag(TAG_TRACK);
|
||||
|
||||
// Clear current contents
|
||||
mLocal.Clear();
|
||||
|
||||
// Load the metadata
|
||||
decltype(mLocal) temp;
|
||||
XMLFileReader reader;
|
||||
if (!reader.Parse(&mLocal, fn)) {
|
||||
if (!reader.Parse(&temp, fn)) {
|
||||
// Inform user of load failure
|
||||
AudacityMessageBox(
|
||||
reader.GetErrorStr(),
|
||||
XO("Error Loading Metadata"),
|
||||
wxOK | wxCENTRE,
|
||||
this);
|
||||
return;
|
||||
}
|
||||
|
||||
// Remember title and track in case they're read only
|
||||
wxString title = mLocal.GetTag(TAG_TITLE);
|
||||
wxString track = mLocal.GetTag(TAG_TRACK);
|
||||
|
||||
// Replace existing tags with loaded ones
|
||||
mLocal = temp;
|
||||
|
||||
// Restore title
|
||||
if (!mEditTitle) {
|
||||
mLocal.SetTag(TAG_TITLE, title);
|
||||
|
|
Loading…
Reference in New Issue