From 2d19c2899a52d50117b8c95589beac0f8854ad59 Mon Sep 17 00:00:00 2001 From: John Maguire Date: Tue, 12 Oct 2010 11:55:45 +0000 Subject: [PATCH] Ignore engine metadata notifications if the song was previously loaded via taglib. Fixes issue #880 Fixes issue #864 Fixes issue #574 --- src/core/song.cpp | 12 +++++++++++- src/core/song.h | 3 +++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/core/song.cpp b/src/core/song.cpp index 79b81358c..78946d3ec 100644 --- a/src/core/song.cpp +++ b/src/core/song.cpp @@ -155,7 +155,8 @@ Song::Private::Private() mtime_(-1), ctime_(-1), filesize_(-1), - filetype_(Type_Unknown) + filetype_(Type_Unknown), + init_from_file_(false) { } @@ -219,6 +220,8 @@ void Song::InitFromFile(const QString& filename, int directory_id) { if(fileref->isNull()) return; + d->init_from_file_ = true; + QFileInfo info(filename); d->basefilename_ = info.fileName(); d->filesize_ = info.size(); @@ -369,6 +372,8 @@ void Song::GuessFileType(TagLib::FileRef* fileref) { void Song::InitFromQuery(const SqlRow& q, int col) { d->valid_ = true; + d->init_from_file_ = true; + #define tostr(n) (q.value(n).isNull() ? QString::null : q.value(n).toString()) #define toint(n) (q.value(n).isNull() ? -1 : q.value(n).toInt()) #define tofloat(n) (q.value(n).isNull() ? -1 : q.value(n).toDouble()) @@ -788,6 +793,11 @@ void Song::InitFromLastFM(const lastfm::Track& track) { void Song::MergeFromSimpleMetaBundle(const Engine::SimpleMetaBundle &bundle) { d->valid_ = true; + if (d->init_from_file_) { + // This Song was already loaded using taglib. Our tags are probably better than the engine's. + return; + } + UniversalEncodingHandler detector(NS_FILTER_NON_CJK); QTextCodec* codec = detector.Guess(bundle); diff --git a/src/core/song.h b/src/core/song.h index 1df810beb..10e863e87 100644 --- a/src/core/song.h +++ b/src/core/song.h @@ -270,6 +270,9 @@ class Song { QString art_manual_; // Set by the user - should take priority QImage image_; + + // Whether this song was loaded from a file using taglib. + bool init_from_file_; }; void ParseOggTag(const TagLib::Ogg::FieldListMap& map, const QTextCodec* codec, QString* disc, QString* compilation);