diff --git a/src/Tags.cpp b/src/Tags.cpp index 31711b157..c1b109b40 100644 --- a/src/Tags.cpp +++ b/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);