FIX used size overflow when multiplied.
This commit is contained in:
parent
27882cdb6a
commit
a9655d7fad
|
@ -52,10 +52,6 @@ void CreateVolumeDialog::setupDialog()
|
|||
dialogWidget().listPV().addPartitionList(FS::lvm2_pv::getFreePV(), false);
|
||||
}
|
||||
|
||||
void CreateVolumeDialog::setupConstraints()
|
||||
{
|
||||
}
|
||||
|
||||
void CreateVolumeDialog::setupConnections()
|
||||
{
|
||||
connect(&dialogWidget().vgName(), &QLineEdit::textChanged, this, &CreateVolumeDialog::onVGNameChanged);
|
||||
|
|
|
@ -31,7 +31,6 @@ public:
|
|||
protected:
|
||||
void accept() override;
|
||||
void setupDialog() override;
|
||||
void setupConstraints() override;
|
||||
void setupConnections() override;
|
||||
|
||||
protected:
|
||||
|
|
|
@ -39,7 +39,6 @@ public:
|
|||
|
||||
QStringList checkedItems();
|
||||
|
||||
protected:
|
||||
QListWidget& listPhysicalVolumes() {
|
||||
Q_ASSERT(m_ListPhysicalVolumes);
|
||||
return *m_ListPhysicalVolumes;
|
||||
|
|
|
@ -62,6 +62,7 @@ void ResizeVolumeDialog::setupConstraints()
|
|||
dialogWidget().vgName().setEnabled(false);
|
||||
dialogWidget().spinPESize().setEnabled(false);
|
||||
dialogWidget().volumeType().setEnabled(false);
|
||||
VolumeDialog::setupConstraints();
|
||||
}
|
||||
|
||||
void ResizeVolumeDialog::accept()
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
|
||||
#include <QPointer>
|
||||
#include <QPushButton>
|
||||
#include <QListWidgetItem>
|
||||
#include <QDialogButtonBox>
|
||||
|
||||
/** Creates a new VolumeDialog
|
||||
|
@ -88,6 +89,10 @@ void VolumeDialog::setupConnections()
|
|||
connect(dialogButtonBox, &QDialogButtonBox::accepted, this, &VolumeDialog::accept);
|
||||
connect(dialogButtonBox, &QDialogButtonBox::rejected, this, &VolumeDialog::reject);
|
||||
connect(&dialogWidget().volumeType(), static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &VolumeDialog::onVolumeTypeChanged);
|
||||
connect(&dialogWidget().listPV().listPhysicalVolumes(), &QListWidget::itemChanged,
|
||||
this, [=] ( QListWidgetItem*) {
|
||||
updateSizeInfos();
|
||||
});
|
||||
}
|
||||
|
||||
void VolumeDialog::setupConstraints()
|
||||
|
@ -130,13 +135,19 @@ void VolumeDialog::updateSizeInfos()
|
|||
if (!checkedPartitions.isEmpty()) {
|
||||
totalSize = FS::lvm2_pv::getPVSize(checkedPartitions);
|
||||
if (peSize > 0) {
|
||||
totalUsedSize = FS::lvm2_pv::getAllocatedPE(checkedPartitions) * peSize;
|
||||
totalSectors = totalSize / peSize;
|
||||
}
|
||||
}
|
||||
|
||||
if (!dialogWidget().vgName().text().isEmpty()) {
|
||||
QStringList lvlist = LvmDevice::getLVs(dialogWidget().vgName().text());
|
||||
QString vgname = dialogWidget().vgName().text();
|
||||
if (!vgname.isEmpty()) {
|
||||
|
||||
// allocated PE and PE size value are both 32 bit. will overflow if stringed together.
|
||||
totalUsedSize = LvmDevice::getAllocatedPE(vgname);
|
||||
totalUsedSize *= LvmDevice::getPeSize(vgname);
|
||||
|
||||
|
||||
QStringList lvlist = LvmDevice::getLVs(vgname);
|
||||
if (!lvlist.isEmpty() ) {
|
||||
totalLV = lvlist.count();
|
||||
}
|
||||
|
@ -159,5 +170,6 @@ void VolumeDialog::onPartitionListChanged()
|
|||
|
||||
void VolumeDialog::onVolumeTypeChanged(int index)
|
||||
{
|
||||
Q_UNUSED(index)
|
||||
updatePartitionList();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue