summaryrefslogtreecommitdiff
path: root/src/db/plugins/simple/ExportedSong.hxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/db/plugins/simple/ExportedSong.hxx')
-rw-r--r--src/db/plugins/simple/ExportedSong.hxx18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/db/plugins/simple/ExportedSong.hxx b/src/db/plugins/simple/ExportedSong.hxx
index 37e4109b5..9a2d54a85 100644
--- a/src/db/plugins/simple/ExportedSong.hxx
+++ b/src/db/plugins/simple/ExportedSong.hxx
@@ -29,6 +29,12 @@
* a #LightSong, e.g. a merged #Tag.
*/
class ExportedSong : public LightSong {
+ /**
+ * A reference target for LightSong::tag, but it is only used
+ * if this instance "owns" the #Tag. For instances referring
+ * to a foreign #Tag instance (e.g. a Song::tag), this field
+ * is not used (and empty).
+ */
Tag tag_buffer;
public:
@@ -42,10 +48,20 @@ public:
points to this instance's #Tag field instead of leaving a
dangling reference to the source object's #Tag field */
ExportedSong(ExportedSong &&src) noexcept
- :LightSong(src, tag_buffer),
+ :LightSong(src,
+ /* refer to tag_buffer only if the
+ moved-from instance also owned the Tag
+ which its LightSong::tag field refers
+ to */
+ OwnsTag() ? tag_buffer : src.tag),
tag_buffer(std::move(src.tag_buffer)) {}
ExportedSong &operator=(ExportedSong &&) = delete;
+
+private:
+ bool OwnsTag() const noexcept {
+ return &tag == &tag_buffer;
+ }
};
#endif