Verified Commit e902231b authored by Daniel Vrátil's avatar Daniel Vrátil 🤖
Browse files

Make ItemPrivate::mParent managed by QScopedPointer

parent 8cade8ed
......@@ -262,7 +262,7 @@ const Attribute *Item::attribute(const QByteArray &type) const
Collection &Item::parentCollection()
{
if (!d_ptr->mParent) {
d_ptr->mParent = new Collection();
d_ptr->mParent.reset(new Collection());
}
return *(d_ptr->mParent);
}
......@@ -278,8 +278,7 @@ Collection Item::parentCollection() const
void Item::setParentCollection(const Collection &parent)
{
delete d_ptr->mParent;
d_ptr->mParent = new Collection(parent);
d_ptr->mParent.reset(new Collection(parent));
}
Item::Flags Item::flags() const
......
......@@ -286,7 +286,6 @@ public:
: QSharedData()
, mRevision(-1)
, mId(id)
, mParent(nullptr)
, mLegacyPayload()
, mPayloads()
, mCollectionId(-1)
......@@ -302,14 +301,13 @@ public:
ItemPrivate(const ItemPrivate &other)
: QSharedData(other)
, mParent(nullptr)
{
mId = other.mId;
mRemoteId = other.mRemoteId;
mRemoteRevision = other.mRemoteRevision;
mPayloadPath = other.mPayloadPath;
if (other.mParent) {
mParent = new Collection(*(other.mParent));
mParent.reset(new Collection(*(other.mParent)));
}
mFlags = other.mFlags;
mRevision = other.mRevision;
......@@ -340,8 +338,6 @@ public:
~ItemPrivate()
{
delete mParent;
ItemChangeLog::instance()->removeItem(this);
}
......@@ -436,7 +432,7 @@ public:
QString mRemoteId;
QString mRemoteRevision;
mutable QString mPayloadPath;
mutable Collection *mParent;
mutable QScopedPointer<Collection> mParent;
mutable _detail::clone_ptr<Internal::PayloadBase> mLegacyPayload;
mutable PayloadContainer mPayloads;
Item::Flags mFlags;
......
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