Sort LVM LV volumes alphabetically.

This commit is contained in:
Andrius Štikonas 2016-11-19 01:36:15 +00:00
parent da0b939bf6
commit 6926046edb
2 changed files with 3 additions and 2 deletions

View File

@ -372,7 +372,7 @@ void PartitionTable::removeUnallocated()
@param p the parent PartitionNode (may be this or an extended Partition) @param p the parent PartitionNode (may be this or an extended Partition)
@param start the first sector to begin looking for free space @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); 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()) { if (d.type() == Device::LVM_Device && !p->children().isEmpty()) {
// rearranging the sectors of all partitions to keep unallocated space at the end // rearranging the sectors of all partitions to keep unallocated space at the end
lastEnd = 0; lastEnd = 0;
qSort(children().begin(), children().end(), [](const Partition* p1, const Partition* p2) { return p1->deviceNode() < p2->deviceNode(); });
for (const auto &child : children()) { for (const auto &child : children()) {
qint64 totalSectors = child->length(); qint64 totalSectors = child->length();
child->setFirstSector(lastEnd); child->setFirstSector(lastEnd);

View File

@ -161,7 +161,7 @@ public:
} }
void updateUnallocated(const Device& d); 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; bool isSectorBased(const Device& d) const;