[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kpmcore] src/core: Handle parent change in Partition copy constructor.
From:       Teo Mrnjavac <teo () kde ! org>
Date:       2016-12-01 18:02:12
Message-ID: E1cCVgS-0006RN-J3 () code ! kde ! org
[Download RAW message or body]

Git commit a749d1c84d79492f9608923be10664f07a056321 by Teo Mrnjavac.
Committed on 01/12/2016 at 18:00.
Pushed by mrnjavac into branch 'master'.

Handle parent change in Partition copy constructor.

M  +5    -3    src/core/partition.cpp
M  +1    -1    src/core/partition.h
M  +1    -1    src/core/partitiontable.cpp

https://commits.kde.org/kpmcore/a749d1c84d79492f9608923be10664f07a056321

diff --git a/src/core/partition.cpp b/src/core/partition.cpp
index 0c8e45b..678d3b2 100644
--- a/src/core/partition.cpp
+++ b/src/core/partition.cpp
@@ -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);
     }
 }
diff --git a/src/core/partition.h b/src/core/partition.h
index 3340e30..239dd6e 100644
--- a/src/core/partition.h
+++ b/src/core/partition.h
@@ -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;
diff --git a/src/core/partitiontable.cpp b/src/core/partitiontable.cpp
index 1f82213..4c86704 100644
--- a/src/core/partitiontable.cpp
+++ b/src/core/partitiontable.cpp
@@ -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));
     }
 }
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic