Merge pull request #2611 from Cacodemon345/qt-cylinderfix

qt: large sizes when entered no longer decrement by 1MB
This commit is contained in:
Miran Grča
2022-08-12 18:59:09 +02:00
committed by GitHub
2 changed files with 7 additions and 0 deletions

View File

@@ -39,6 +39,7 @@ extern "C" {
#include <QPushButton> #include <QPushButton>
#include <QStringBuilder> #include <QStringBuilder>
#include <QStringList> #include <QStringList>
#include <QTimer>
#include "qt_harddrive_common.hpp" #include "qt_harddrive_common.hpp"
#include "qt_settings_bus_tracking.hpp" #include "qt_settings_bus_tracking.hpp"
@@ -608,6 +609,7 @@ void HarddiskDialog::onExistingFileSelected(const QString &fileName) {
} }
void HarddiskDialog::recalcSize() { void HarddiskDialog::recalcSize() {
if (disallowSizeModifications) return;
uint64_t size = (static_cast<uint64_t>(cylinders_) * static_cast<uint64_t>(heads_) * static_cast<uint64_t>(sectors_)) << 9; uint64_t size = (static_cast<uint64_t>(cylinders_) * static_cast<uint64_t>(heads_) * static_cast<uint64_t>(sectors_)) << 9;
ui->lineEditSize->setText(QString::number(size >> 20)); ui->lineEditSize->setText(QString::number(size >> 20));
} }
@@ -731,6 +733,7 @@ void HarddiskDialog::on_comboBoxBus_currentIndexChanged(int index) {
} }
void HarddiskDialog::on_lineEditSize_textEdited(const QString &text) { void HarddiskDialog::on_lineEditSize_textEdited(const QString &text) {
disallowSizeModifications = true;
uint32_t size = text.toUInt(); uint32_t size = text.toUInt();
/* This is needed to ensure VHD standard compliance. */ /* This is needed to ensure VHD standard compliance. */
hdd_image_calc_chs(&cylinders_, &heads_, &sectors_, size); hdd_image_calc_chs(&cylinders_, &heads_, &sectors_, size);
@@ -742,6 +745,8 @@ void HarddiskDialog::on_lineEditSize_textEdited(const QString &text) {
checkAndAdjustCylinders(); checkAndAdjustCylinders();
checkAndAdjustHeads(); checkAndAdjustHeads();
checkAndAdjustSectors(); checkAndAdjustSectors();
disallowSizeModifications = false;
} }
void HarddiskDialog::on_lineEditCylinders_textEdited(const QString &text) { void HarddiskDialog::on_lineEditCylinders_textEdited(const QString &text) {

View File

@@ -49,6 +49,8 @@ private:
uint32_t max_sectors = 0; uint32_t max_sectors = 0;
uint32_t max_heads = 0; uint32_t max_heads = 0;
uint32_t max_cylinders = 0; uint32_t max_cylinders = 0;
bool disallowSizeModifications = false;
bool checkAndAdjustCylinders(); bool checkAndAdjustCylinders();
bool checkAndAdjustHeads(); bool checkAndAdjustHeads();