VirtualBox

Changeset 76199 in vbox


Ignore:
Timestamp:
Dec 13, 2018 9:08:47 AM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9335. In virtual medium size editor, Check line edit values if they are multiple of 512 bytes.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/widgets
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIMediumSizeEditor.cpp

    r71922 r76199  
    3636#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
    3737
     38const qulonglong UIMediumSizeEditor::m_uSectorSize = 512;
    3839
    3940UIMediumSizeEditor::UIMediumSizeEditor(QWidget *pParent /* = 0 */)
     
    108109    /* Notify the listeners: */
    109110    emit sigSizeChanged(m_uSize);
     111}
     112
     113void UIMediumSizeEditor::sltSizeEditorEditingFinished()
     114{
     115    qulonglong uSize = checkSectorSizeAlignment(m_uSize);
     116
     117    /* The size is already aligned to sector size: */
     118    if (uSize == m_uSize)
     119        return;
     120    setMediumSize(uSize);
    110121}
    111122
     
    176187            connect(m_pEditor, &QILineEdit::textChanged,
    177188                    this, &UIMediumSizeEditor::sltSizeEditorChanged);
     189            connect(m_pEditor, &QILineEdit::editingFinished,
     190                    this, &UIMediumSizeEditor::sltSizeEditorEditingFinished);
    178191
    179192            /* Add into layout: */
     
    229242int UIMediumSizeEditor::sizeMBToSlider(qulonglong uValue, int iSliderScale)
    230243{
    231     /* Make sure *any* slider value is multiple of 512: */
    232     uValue /= 512;
     244    /* Make sure *any* slider value is multiple of m_uSectorSize: */
     245    uValue /= m_uSectorSize;
    233246
    234247    /* Calculate result: */
     
    253266    qulonglong uResult = uTickMB + (uTickMBNext - uTickMB) * iStep / iSliderScale;
    254267
    255     /* Make sure *any* slider value is multiple of 512: */
    256     uResult *= 512;
     268    /* Make sure *any* slider value is multiple of m_uSectorSize: */
     269    uResult *= m_uSectorSize;
    257270
    258271    /* Return result: */
     
    266279    m_pEditor->setToolTip(strToolTip);
    267280}
     281
     282qulonglong UIMediumSizeEditor::checkSectorSizeAlignment(qulonglong uSize)
     283{
     284    if (m_uSectorSize == 0 || uSize % m_uSectorSize == 0)
     285        return uSize;
     286    qulonglong uNewSize = (uSize / m_uSectorSize) * m_uSectorSize;
     287    return uNewSize;
     288}
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIMediumSizeEditor.h

    r71922 r76199  
    6464    /** Handles size editor change. */
    6565    void sltSizeEditorChanged(const QString &strValue);
     66    void sltSizeEditorEditingFinished();
    6667
    6768private:
     
    8081    /** Updates slider/editor tool-tips. */
    8182    void updateSizeToolTips(qulonglong uSize);
     83    /** Checks if the uSize is divisible by m_uSectorSize */
     84    qulonglong checkSectorSizeAlignment(qulonglong uSize);
    8285
     86    /* Holds the block size. We force m_uSize to be multiple of this number. */
     87    static const qulonglong m_uSectorSize;
    8388    /** Holds the minimum medium size. */
    8489    const qulonglong  m_uSizeMin;
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette