Handle parent change in Partition copy constructor.

This commit is contained in:
Teo Mrnjavac 2016-12-01 19:00:15 +01:00
parent 2e960d5c00
commit a749d1c84d
3 changed files with 7 additions and 5 deletions

View File

@ -90,7 +90,7 @@ Partition::~Partition()
/** @param other Partition to copy
*/
Partition::Partition(const Partition& other) :
Partition::Partition(const Partition& other, PartitionNode* parent) :
PartitionNode(),
m_Children(),
m_Parent(other.m_Parent),
@ -106,10 +106,12 @@ Partition::Partition(const Partition& other) :
m_SectorSize(other.m_SectorSize),
m_State(other.m_State)
{
if ( parent )
m_Parent = parent;
setPartitionPath(other.m_PartitionPath);
for (const auto &child : other.children()) {
Partition* p = new Partition(*child);
p->setParent(this);
Partition* p = new Partition(*child, this);
m_Children.append(p);
}
}

View File

@ -116,7 +116,7 @@ public:
Partition(PartitionNode* parent, const Device& device, const PartitionRole& role, FileSystem* fs, qint64 sectorStart, qint64 sectorEnd, QString partitionPath, PartitionTable::Flags availableFlags = PartitionTable::FlagNone, const QString& mountPoint = QString(), bool mounted = false, PartitionTable::Flags activeFlags = PartitionTable::FlagNone, State state = StateNone);
~Partition();
Partition(const Partition&);
Partition(const Partition& other, PartitionNode* parent = nullptr);
Partition& operator=(const Partition&);
bool operator==(const Partition& other) const;

View File

@ -63,7 +63,7 @@ PartitionTable::PartitionTable(const PartitionTable& other)
for (Partitions::const_iterator it = other.m_Children.constBegin();
it != other.m_Children.constEnd(); ++it)
{
m_Children.append(new Partition(**it));
m_Children.append(new Partition(**it, this));
}
}