From c63892bcdce84f029f1cdac417fc5a5de00f8b51 Mon Sep 17 00:00:00 2001 From: casey langen Date: Mon, 5 Oct 2020 22:03:26 -0700 Subject: [PATCH] Fixed a couple really old LibraryTrack bugs caused by code that was never exercised. --- src/core/library/track/LibraryTrack.cpp | 17 +++++++++++++---- src/core/library/track/Track.cpp | 4 ++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/core/library/track/LibraryTrack.cpp b/src/core/library/track/LibraryTrack.cpp index fdc4f0e29..1a79e6480 100644 --- a/src/core/library/track/LibraryTrack.cpp +++ b/src/core/library/track/LibraryTrack.cpp @@ -69,8 +69,11 @@ LibraryTrack::~LibraryTrack() { std::string LibraryTrack::GetString(const char* metakey) { std::unique_lock lock(this->mutex); MetadataMap::iterator metavalue = this->metadata.find(metakey); - if (metavalue != this->metadata.end()) { - return metavalue->second; + while (metavalue != this->metadata.end()) { + if (metavalue->second.size() > 0) { + return metavalue->second; + } + ++metavalue; } return ""; } @@ -112,8 +115,14 @@ double LibraryTrack::GetDouble(const char* key, double defaultValue) { } void LibraryTrack::SetValue(const char* metakey, const char* value) { - std::unique_lock lock(this->mutex); - this->metadata.insert(std::pair(metakey,value)); + if (value) { + std::string strValue(value); + if (strValue.size()) { + std::unique_lock lock(this->mutex); + this->metadata.insert(std::pair(metakey, strValue)); + } + + } } void LibraryTrack::ClearValue(const char* metakey) { diff --git a/src/core/library/track/Track.cpp b/src/core/library/track/Track.cpp index 5cdd649db..8a579548f 100644 --- a/src/core/library/track/Track.cpp +++ b/src/core/library/track/Track.cpp @@ -66,6 +66,10 @@ class SdkWrapper : public Track { } } + virtual int64_t GetId() { + return track->GetId(); + } + virtual int GetString(const char* key, char* dst, int size) override { return track->GetString(key, dst, size); }