diff --git a/src/core/partitiontable.cpp b/src/core/partitiontable.cpp index b54be1a..9f92120 100644 --- a/src/core/partitiontable.cpp +++ b/src/core/partitiontable.cpp @@ -372,7 +372,7 @@ void PartitionTable::removeUnallocated() @param p the parent PartitionNode (may be this or an extended Partition) @param start the first sector to begin looking for free space */ -void PartitionTable::insertUnallocated(const Device& d, PartitionNode* p, qint64 start) const +void PartitionTable::insertUnallocated(const Device& d, PartitionNode* p, qint64 start) { Q_ASSERT(p); @@ -381,6 +381,7 @@ void PartitionTable::insertUnallocated(const Device& d, PartitionNode* p, qint64 if (d.type() == Device::LVM_Device && !p->children().isEmpty()) { // rearranging the sectors of all partitions to keep unallocated space at the end lastEnd = 0; + qSort(children().begin(), children().end(), [](const Partition* p1, const Partition* p2) { return p1->deviceNode() < p2->deviceNode(); }); for (const auto &child : children()) { qint64 totalSectors = child->length(); child->setFirstSector(lastEnd); diff --git a/src/core/partitiontable.h b/src/core/partitiontable.h index 929fd8e..253cc44 100644 --- a/src/core/partitiontable.h +++ b/src/core/partitiontable.h @@ -161,7 +161,7 @@ public: } void updateUnallocated(const Device& d); - void insertUnallocated(const Device& d, PartitionNode* p, qint64 start) const; + void insertUnallocated(const Device& d, PartitionNode* p, qint64 start); bool isSectorBased(const Device& d) const;