mirror of
https://github.com/cookiengineer/audacity
synced 2025-05-01 16:19:43 +02:00
Bug 440 - Metadata Editor: Tags without values can't be added
This commit is contained in:
parent
07465845dd
commit
9d1b75a5d7
17
src/Tags.cpp
17
src/Tags.cpp
@ -477,7 +477,7 @@ Tags::Iterators Tags::GetRange() const
|
|||||||
return { mMap.begin(), mMap.end() };
|
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
|
// We don't like empty names
|
||||||
if (name.empty()) {
|
if (name.empty()) {
|
||||||
@ -497,7 +497,10 @@ void Tags::SetTag(const wxString & name, const wxString & value)
|
|||||||
// Look it up
|
// Look it up
|
||||||
TagMap::iterator iter = mXref.find(key);
|
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
|
// Erase the tag
|
||||||
if (iter == mXref.end())
|
if (iter == mXref.end())
|
||||||
// nothing to do
|
// nothing to do
|
||||||
@ -507,7 +510,8 @@ void Tags::SetTag(const wxString & name, const wxString & value)
|
|||||||
mXref.erase(iter);
|
mXref.erase(iter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
if (iter == mXref.end()) {
|
if (iter == mXref.end()) {
|
||||||
// Didn't find the tag
|
// Didn't find the tag
|
||||||
|
|
||||||
@ -1002,6 +1006,8 @@ bool TagsEditor::TransferDataFromWindow()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool bSpecialTag = true;
|
||||||
|
|
||||||
// Map special tag names back to internal keys
|
// Map special tag names back to internal keys
|
||||||
if (n.CmpNoCase(wxGetTranslation(LABEL_ARTIST)) == 0) {
|
if (n.CmpNoCase(wxGetTranslation(LABEL_ARTIST)) == 0) {
|
||||||
n = TAG_ARTIST;
|
n = TAG_ARTIST;
|
||||||
@ -1024,8 +1030,11 @@ bool TagsEditor::TransferDataFromWindow()
|
|||||||
else if (n.CmpNoCase(wxGetTranslation(LABEL_COMMENTS)) == 0) {
|
else if (n.CmpNoCase(wxGetTranslation(LABEL_COMMENTS)) == 0) {
|
||||||
n = TAG_COMMENTS;
|
n = TAG_COMMENTS;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
bSpecialTag = false;
|
||||||
|
}
|
||||||
|
|
||||||
mLocal.SetTag(n, v);
|
mLocal.SetTag(n, v, bSpecialTag);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -114,7 +114,7 @@ class AUDACITY_DLL_API Tags final
|
|||||||
using Iterators = IteratorRange<TagMap::const_iterator>;
|
using Iterators = IteratorRange<TagMap::const_iterator>;
|
||||||
Iterators GetRange() const;
|
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);
|
void SetTag(const wxString & name, const int & value);
|
||||||
|
|
||||||
bool IsEmpty();
|
bool IsEmpty();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user