Check if PartitionNode::insert returns success.

This commit is contained in:
Andrius Štikonas 2018-10-19 20:18:39 +01:00
parent b06af11357
commit d17615532a
1 changed files with 7 additions and 4 deletions

View File

@ -51,11 +51,14 @@ void Operation::insertPreviewPartition(Device& device, Partition& p)
device.partitionTable()->removeUnallocated();
p.parent()->insert(&p);
if (device.type() == Device::Type::LVM_Device) {
const LvmDevice& lvm = static_cast<const LvmDevice&>(device);
lvm.setFreePE(lvm.freePE() - p.length());
if (p.parent()->insert(&p)) {
if (device.type() == Device::Type::LVM_Device) {
const LvmDevice& lvm = static_cast<const LvmDevice&>(device);
lvm.setFreePE(lvm.freePE() - p.length());
}
}
else
qWarning() << "failed to insert preview partition " << p.deviceNode() << " at " << &p << ".";
device.partitionTable()->updateUnallocated(device);
}