From 9d1b75a5d75ad6f5449c22e5cace83f4aa387c10 Mon Sep 17 00:00:00 2001 From: James Crook Date: Wed, 17 Jul 2019 15:02:28 +0100 Subject: [PATCH] Bug 440 - Metadata Editor: Tags without values can't be added --- src/Tags.cpp | 17 +++++++++++++---- src/Tags.h | 2 +- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/Tags.cpp b/src/Tags.cpp index 8eeb7845f..d9e484782 100644 --- a/src/Tags.cpp +++ b/src/Tags.cpp @@ -477,7 +477,7 @@ Tags::Iterators Tags::GetRange() const return { mMap.begin(), mMap.end() }; } -void Tags::SetTag(const wxString & name, const wxString & value) +void Tags::SetTag(const wxString & name, const wxString & value, const bool bSpecialTag) { // We don't like empty names if (name.empty()) { @@ -497,7 +497,10 @@ void Tags::SetTag(const wxString & name, const wxString & value) // Look it up TagMap::iterator iter = mXref.find(key); - if (value.empty()) { + // The special tags, if empty, should not exist. + // However it is allowable for a custom tag to be empty. + // See Bug 440 and Bug 1382 + if (value.empty() && bSpecialTag) { // Erase the tag if (iter == mXref.end()) // nothing to do @@ -507,7 +510,8 @@ void Tags::SetTag(const wxString & name, const wxString & value) mXref.erase(iter); } } - else { + else + { if (iter == mXref.end()) { // Didn't find the tag @@ -1002,6 +1006,8 @@ bool TagsEditor::TransferDataFromWindow() continue; } + bool bSpecialTag = true; + // Map special tag names back to internal keys if (n.CmpNoCase(wxGetTranslation(LABEL_ARTIST)) == 0) { n = TAG_ARTIST; @@ -1024,8 +1030,11 @@ bool TagsEditor::TransferDataFromWindow() else if (n.CmpNoCase(wxGetTranslation(LABEL_COMMENTS)) == 0) { n = TAG_COMMENTS; } + else { + bSpecialTag = false; + } - mLocal.SetTag(n, v); + mLocal.SetTag(n, v, bSpecialTag); } return true; diff --git a/src/Tags.h b/src/Tags.h index ae882e3fc..2d2a4b479 100644 --- a/src/Tags.h +++ b/src/Tags.h @@ -114,7 +114,7 @@ class AUDACITY_DLL_API Tags final using Iterators = IteratorRange; Iterators GetRange() const; - void SetTag(const wxString & name, const wxString & value); + void SetTag(const wxString & name, const wxString & value, const bool bSpecialTag=false); void SetTag(const wxString & name, const int & value); bool IsEmpty();