diff --git a/taglib/ogg/xiphcomment.cpp b/taglib/ogg/xiphcomment.cpp index 090675c2..e5b2fc8e 100644 --- a/taglib/ogg/xiphcomment.cpp +++ b/taglib/ogg/xiphcomment.cpp @@ -137,7 +137,14 @@ void Ogg::XiphComment::setAlbum(const String &s) void Ogg::XiphComment::setComment(const String &s) { - addField(d->commentField.isEmpty() ? "DESCRIPTION" : d->commentField, s); + if(d->commentField.isEmpty()) { + if(!d->fieldListMap["DESCRIPTION"].isEmpty()) + d->commentField = "DESCRIPTION"; + else + d->commentField = "COMMENT"; + } + + addField(d->commentField, s); } void Ogg::XiphComment::setGenre(const String &s) diff --git a/tests/test_xiphcomment.cpp b/tests/test_xiphcomment.cpp index 6526229b..e2358333 100644 --- a/tests/test_xiphcomment.cpp +++ b/tests/test_xiphcomment.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -17,6 +18,7 @@ class TestXiphComment : public CppUnit::TestFixture CPPUNIT_TEST(testTrack); CPPUNIT_TEST(testSetTrack); CPPUNIT_TEST(testInvalidKeys); + CPPUNIT_TEST(testClearComment); CPPUNIT_TEST_SUITE_END(); public: @@ -74,6 +76,22 @@ public: CPPUNIT_ASSERT(cmt.properties().isEmpty()); } + void testClearComment() + { + ScopedFileCopy copy("no-tags", ".flac"); + + { + FLAC::File f(copy.fileName().c_str()); + f.xiphComment()->addField("COMMENT", "Comment1"); + f.save(); + } + { + FLAC::File f(copy.fileName().c_str()); + f.xiphComment()->setComment(""); + CPPUNIT_ASSERT_EQUAL(String(""), f.xiphComment()->comment()); + } + } + }; CPPUNIT_TEST_SUITE_REGISTRATION(TestXiphComment);