Commit 14d2d4a6 authored by Alberto Mardegan's avatar Alberto Mardegan

Writer: keep Metadata alive

Put the Metadata class as a member of Writer, in order to ensure it has
the same lifetime.
Then there's no need to keep the boolean "embed" field: we just mirror
the one from Metadata.
parent da854c94
......@@ -60,16 +60,17 @@ public:
void setPhotoTags(QList<PhotoId> ids, const QList<Tag> &tags, bool adding);
private:
bool m_embed;
Metadata m_metadata;
mutable Writer *q_ptr;
};
} // namespace
WriterPrivate::WriterPrivate(Writer *q):
m_embed(false),
q_ptr(q)
{
QObject::connect(&m_metadata, SIGNAL(embedChanged()),
q, SIGNAL(embedChanged()));
}
WriterPrivate::~WriterPrivate()
......@@ -81,9 +82,6 @@ void WriterPrivate::setPhotoTags(QList<PhotoId> ids, const QList<Tag> &tags,
{
Database *db = Database::instance();
Metadata metadata;
metadata.setEmbed(m_embed);
db->transaction();
Q_FOREACH(PhotoId id, ids) {
......@@ -111,8 +109,8 @@ void WriterPrivate::setPhotoTags(QList<PhotoId> ids, const QList<Tag> &tags,
db->setTags(id, tags);
}
metadata.writeTags(photo.url().toLocalFile(),
Tag::tagNames(metadataTags));
m_metadata.writeTags(photo.url().toLocalFile(),
Tag::tagNames(metadataTags));
}
db->commit();
......@@ -132,15 +130,13 @@ Writer::~Writer()
void Writer::setEmbed(bool embed)
{
Q_D(Writer);
if (d->m_embed == embed) return;
d->m_embed = embed;
Q_EMIT embedChanged();
d->m_metadata.setEmbed(embed);
}
bool Writer::embed() const
{
Q_D(const Writer);
return d->m_embed;
return d->m_metadata.embed();
}
void Writer::setPhotoTags(const QVariant &photoIds, const QList<Tag> &tags)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment