Bug1382: Should not make an undo item when exporting with no metadata changes
This commit is contained in:
parent
36e6bffa01
commit
a0290c09d2
|
@ -5597,9 +5597,11 @@ bool AudacityProject::DoEditMetadata
|
|||
auto newTags = mTags->Duplicate();
|
||||
|
||||
if (newTags->ShowEditDialog(this, title, force)) {
|
||||
// Commit the change to project state only now.
|
||||
mTags = newTags;
|
||||
PushState(title, shortUndoDescription);
|
||||
if (*mTags != *newTags) {
|
||||
// Commit the change to project state only now.
|
||||
mTags = newTags;
|
||||
PushState(title, shortUndoDescription);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
36
src/Tags.cpp
36
src/Tags.cpp
|
@ -302,6 +302,42 @@ void Tags::Clear()
|
|||
mMap.clear();
|
||||
}
|
||||
|
||||
namespace {
|
||||
bool EqualMaps(const TagMap &map1, const TagMap &map2)
|
||||
{
|
||||
for (auto it1 = map1.begin(), end1 = map1.end(),
|
||||
it2 = map2.begin(), end2 = map2.end();
|
||||
it1 != end1 || it2 != end2;) {
|
||||
if (it1 == end1 || it2 == end2)
|
||||
return false;
|
||||
else if (it1->first != it2->first)
|
||||
return false;
|
||||
else if (it1->second != it2->second)
|
||||
return false;
|
||||
else
|
||||
++it1, ++it2;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool operator== (const Tags &lhs, const Tags &rhs)
|
||||
{
|
||||
if (!EqualMaps(lhs.mXref, rhs.mXref))
|
||||
return false;
|
||||
|
||||
if (!EqualMaps(lhs.mMap, rhs.mMap))
|
||||
return false;
|
||||
|
||||
return
|
||||
lhs.mGenres == rhs.mGenres
|
||||
&&
|
||||
lhs.mEditTitle == rhs.mEditTitle
|
||||
&&
|
||||
lhs.mEditTrackNumber == rhs.mEditTrackNumber
|
||||
;
|
||||
}
|
||||
|
||||
void Tags::AllowEditTitle(bool editTitle)
|
||||
{
|
||||
mEditTitle = editTitle;
|
||||
|
|
|
@ -118,6 +118,8 @@ class AUDACITY_DLL_API Tags final : public XMLTagHandler {
|
|||
bool IsEmpty();
|
||||
void Clear();
|
||||
|
||||
friend bool operator == (const Tags &lhs, const Tags &rhs);
|
||||
|
||||
private:
|
||||
void LoadDefaults();
|
||||
|
||||
|
@ -130,6 +132,9 @@ class AUDACITY_DLL_API Tags final : public XMLTagHandler {
|
|||
bool mEditTrackNumber;
|
||||
};
|
||||
|
||||
inline bool operator != (const Tags &lhs, const Tags &rhs)
|
||||
{ return !(lhs == rhs); }
|
||||
|
||||
class TagsEditor final : public wxDialog
|
||||
{
|
||||
public:
|
||||
|
|
Loading…
Reference in New Issue