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

Make CollectionPrivate::mParent managed by QScopedPointer

parent 0119e48d
......@@ -203,9 +203,9 @@ const Attribute *Collection::attribute(const QByteArray &type) const
Collection &Collection::parentCollection()
{
if (!d_ptr->mParent) {
d_ptr->mParent = new Collection();
d_ptr->mParent.reset(new Collection());
}
return *(d_ptr->mParent);
return *d_ptr->mParent.get();
}
Collection Collection::parentCollection() const
......@@ -213,14 +213,13 @@ Collection Collection::parentCollection() const
if (!d_ptr->mParent) {
return *(s_defaultParentCollection);
} else {
return *(d_ptr->mParent);
return *d_ptr->mParent.get();
}
}
void Collection::setParentCollection(const Collection &parent)
{
delete d_ptr->mParent;
d_ptr->mParent = new Collection(parent);
d_ptr->mParent.reset(new Collection(parent));
}
QString Collection::name() const
......
......@@ -49,20 +49,18 @@ public:
, cachePolicyChanged(false)
, isVirtual(false)
, mId(id)
, mParent(nullptr)
{
}
CollectionPrivate(const CollectionPrivate &other)
: QSharedData(other)
, mParent(nullptr)
{
mId = other.mId;
mRemoteId = other.mRemoteId;
mRemoteRevision = other.mRemoteRevision;
mAttributeStorage = other.mAttributeStorage;
if (other.mParent) {
mParent = new Collection(*(other.mParent));
mParent.reset(new Collection(*(other.mParent)));
}
name = other.name;
resource = other.resource;
......@@ -81,11 +79,6 @@ public:
keepLocalChanges = other.keepLocalChanges;
}
~CollectionPrivate()
{
delete mParent;
}
void resetChangeLog()
{
contentTypesChanged = false;
......@@ -117,7 +110,7 @@ public:
Collection::Id mId;
QString mRemoteId;
QString mRemoteRevision;
mutable Collection *mParent;
mutable QScopedPointer<Collection> mParent;
AttributeStorage mAttributeStorage;
QString name;
QString resource;
......
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