VirtualBox

Changeset 94667 in vbox


Ignore:
Timestamp:
Apr 21, 2022 11:31:58 AM (3 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
151031
Message:

FE/Qt/Ds: bugref:6899: Machine settings: Sanity checks for settings loading/saving.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsAudio.cpp

    r94333 r94667  
    9393bool UIMachineSettingsAudio::changed() const
    9494{
    95     return m_pCache->wasChanged();
     95    return m_pCache ? m_pCache->wasChanged() : false;
    9696}
    9797
    9898void UIMachineSettingsAudio::loadToCacheFrom(QVariant &data)
    9999{
     100    /* Sanity check: */
     101    if (!m_pCache)
     102        return;
     103
    100104    /* Fetch data to machine: */
    101105    UISettingsPageMachine::fetchData(data);
     
    104108    m_pCache->clear();
    105109
    106     /* Prepare old audio data: */
     110    /* Prepare old data: */
    107111    UIDataSettingsMachineAudio oldAudioData;
    108112
     
    111115    if (!comAdapter.isNull())
    112116    {
    113         /* Gather old audio data: */
     117        /* Gather old data: */
    114118        oldAudioData.m_fAudioEnabled = comAdapter.GetEnabled();
    115119        oldAudioData.m_audioDriverType = comAdapter.GetAudioDriver();
     
    119123    }
    120124
    121     /* Cache old audio data: */
     125    /* Cache old data: */
    122126    m_pCache->cacheInitialData(oldAudioData);
    123127
     
    128132void UIMachineSettingsAudio::getFromCache()
    129133{
    130     /* Get old audio data from cache: */
     134    /* Sanity check: */
     135    if (!m_pCache)
     136        return;
     137
     138    /* Get old data from cache: */
    131139    const UIDataSettingsMachineAudio &oldAudioData = m_pCache->base();
    132140
    133     /* Load old audio data from cache: */
     141    /* Load old data from cache: */
    134142    m_pCheckBoxAudio->setChecked(oldAudioData.m_fAudioEnabled);
    135     m_pEditorAudioHostDriver->setValue(oldAudioData.m_audioDriverType);
    136     m_pEditorAudioController->setValue(oldAudioData.m_audioControllerType);
    137     m_pEditorAudioFeatures->setEnableOutput(oldAudioData.m_fAudioOutputEnabled);
    138     m_pEditorAudioFeatures->setEnableInput(oldAudioData.m_fAudioInputEnabled);
     143    if (m_pEditorAudioHostDriver)
     144        m_pEditorAudioHostDriver->setValue(oldAudioData.m_audioDriverType);
     145    if (m_pEditorAudioController)
     146        m_pEditorAudioController->setValue(oldAudioData.m_audioControllerType);
     147    if (m_pEditorAudioFeatures)
     148    {
     149        m_pEditorAudioFeatures->setEnableOutput(oldAudioData.m_fAudioOutputEnabled);
     150        m_pEditorAudioFeatures->setEnableInput(oldAudioData.m_fAudioInputEnabled);
     151    }
    139152
    140153    /* Polish page finally: */
     
    144157void UIMachineSettingsAudio::putToCache()
    145158{
    146     /* Prepare new audio data: */
     159    /* Sanity check: */
     160    if (!m_pCache)
     161        return;
     162
     163    /* Prepare new data: */
    147164    UIDataSettingsMachineAudio newAudioData;
    148165
    149     /* Gather new audio data: */
    150     newAudioData.m_fAudioEnabled = m_pCheckBoxAudio->isChecked();
    151     newAudioData.m_audioDriverType = m_pEditorAudioHostDriver->value();
    152     newAudioData.m_audioControllerType = m_pEditorAudioController->value();
    153     newAudioData.m_fAudioOutputEnabled = m_pEditorAudioFeatures->outputEnabled();
    154     newAudioData.m_fAudioInputEnabled = m_pEditorAudioFeatures->inputEnabled();
    155 
    156     /* Cache new audio data: */
     166    /* Cache new data: */
     167    if (m_pCheckBoxAudio)
     168        newAudioData.m_fAudioEnabled = m_pCheckBoxAudio->isChecked();
     169    if (m_pEditorAudioHostDriver)
     170        newAudioData.m_audioDriverType = m_pEditorAudioHostDriver->value();
     171    if (m_pEditorAudioController)
     172        newAudioData.m_audioControllerType = m_pEditorAudioController->value();
     173    if (m_pEditorAudioFeatures)
     174    {
     175        newAudioData.m_fAudioOutputEnabled = m_pEditorAudioFeatures->outputEnabled();
     176        newAudioData.m_fAudioInputEnabled = m_pEditorAudioFeatures->inputEnabled();
     177    }
    157178    m_pCache->cacheCurrentData(newAudioData);
    158179}
     
    273294bool UIMachineSettingsAudio::saveData()
    274295{
     296    /* Sanity check: */
     297    if (!m_pCache)
     298        return false;
     299
    275300    /* Prepare result: */
    276301    bool fSuccess = true;
     
    278303    if (fSuccess && isMachineInValidMode() && m_pCache->wasChanged())
    279304    {
    280         /* Get old audio data from cache: */
     305        /* Get old data from cache: */
    281306        const UIDataSettingsMachineAudio &oldAudioData = m_pCache->base();
    282         /* Get new audio data from cache: */
     307        /* Get new data from cache: */
    283308        const UIDataSettingsMachineAudio &newAudioData = m_pCache->data();
    284309
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsDisplay.cpp

    r94436 r94667  
    355355bool UIMachineSettingsDisplay::changed() const
    356356{
    357     return m_pCache->wasChanged();
     357    return m_pCache ? m_pCache->wasChanged() : false;
    358358}
    359359
    360360void UIMachineSettingsDisplay::loadToCacheFrom(QVariant &data)
    361361{
     362    /* Sanity check: */
     363    if (!m_pCache)
     364        return;
     365
    362366    /* Fetch data to machine: */
    363367    UISettingsPageMachine::fetchData(data);
     
    366370    m_pCache->clear();
    367371
    368     /* Prepare old display data: */
     372    /* Prepare old data: */
    369373    UIDataSettingsMachineDisplay oldDisplayData;
    370374
     
    423427    }
    424428
    425     /* Cache old display data: */
     429    /* Cache old data: */
    426430    m_pCache->cacheInitialData(oldDisplayData);
    427431
     
    432436void UIMachineSettingsDisplay::getFromCache()
    433437{
    434     /* Get old display data from cache: */
     438    /* Sanity check: */
     439    if (!m_pCache)
     440        return;
     441
     442    /* Get old data from cache: */
    435443    const UIDataSettingsMachineDisplay &oldDisplayData = m_pCache->base();
    436444
    437445    /* Load old 'Screen' data from cache: */
    438     m_pEditorMonitorCount->setValue(oldDisplayData.m_cGuestScreenCount);
    439     m_pEditorScaleFactor->setScaleFactors(oldDisplayData.m_scaleFactors);
    440     m_pEditorScaleFactor->setMonitorCount(oldDisplayData.m_cGuestScreenCount);
    441     m_pEditorGraphicsController->setValue(oldDisplayData.m_graphicsControllerType);
    442 #ifdef VBOX_WITH_3D_ACCELERATION
    443     m_pEditorDisplayScreenFeatures->setEnable3DAcceleration(oldDisplayData.m_f3dAccelerationEnabled);
     446    if (m_pEditorMonitorCount)
     447        m_pEditorMonitorCount->setValue(oldDisplayData.m_cGuestScreenCount);
     448    if (m_pEditorScaleFactor)
     449    {
     450        m_pEditorScaleFactor->setScaleFactors(oldDisplayData.m_scaleFactors);
     451        m_pEditorScaleFactor->setMonitorCount(oldDisplayData.m_cGuestScreenCount);
     452    }
     453    if (m_pEditorGraphicsController)
     454        m_pEditorGraphicsController->setValue(oldDisplayData.m_graphicsControllerType);
     455#ifdef VBOX_WITH_3D_ACCELERATION
     456    if (m_pEditorDisplayScreenFeatures)
     457        m_pEditorDisplayScreenFeatures->setEnable3DAcceleration(oldDisplayData.m_f3dAccelerationEnabled);
    444458#endif
    445459    /* Push required value to m_pEditorVideoMemorySize: */
     
    450464#endif
    451465    // Should be the last one for this tab, since it depends on some of others:
    452     m_pEditorVideoMemorySize->setValue(oldDisplayData.m_iCurrentVRAM);
     466    if (m_pEditorVideoMemorySize)
     467        m_pEditorVideoMemorySize->setValue(oldDisplayData.m_iCurrentVRAM);
    453468
    454469    /* If remote display server is supported: */
     
    456471    {
    457472        /* Load old 'Remote Display' data from cache: */
    458         m_pEditorVRDESettings->setFeatureEnabled(oldDisplayData.m_fRemoteDisplayServerEnabled);
    459         m_pEditorVRDESettings->setPort(oldDisplayData.m_strRemoteDisplayPort);
    460         m_pEditorVRDESettings->setAuthType(oldDisplayData.m_remoteDisplayAuthType);
    461         m_pEditorVRDESettings->setTimeout(QString::number(oldDisplayData.m_uRemoteDisplayTimeout));
    462         m_pEditorVRDESettings->setMultipleConnectionsAllowed(oldDisplayData.m_fRemoteDisplayMultiConnAllowed);
    463     }
    464 
    465     /* Load old 'Recording' data from cache: */
    466     m_pEditorRecordingSettings->setFeatureEnabled(oldDisplayData.m_fRecordingEnabled);
    467     m_pEditorRecordingSettings->setFolder(oldDisplayData.m_strRecordingFolder);
    468     m_pEditorRecordingSettings->setFilePath(oldDisplayData.m_strRecordingFilePath);
    469     m_pEditorRecordingSettings->setFrameWidth(oldDisplayData.m_iRecordingVideoFrameWidth);
    470     m_pEditorRecordingSettings->setFrameHeight(oldDisplayData.m_iRecordingVideoFrameHeight);
    471     m_pEditorRecordingSettings->setFrameRate(oldDisplayData.m_iRecordingVideoFrameRate);
    472     m_pEditorRecordingSettings->setBitRate(oldDisplayData.m_iRecordingVideoBitRate);
    473     m_pEditorRecordingSettings->setScreens(oldDisplayData.m_vecRecordingScreens);
    474 
    475     /* Load old 'Recording' options: */
    476     const bool fRecordVideo =
    477         UIDataSettingsMachineDisplay::isRecordingOptionEnabled(oldDisplayData.m_strRecordingVideoOptions,
    478                                                                UIDataSettingsMachineDisplay::RecordingOption_VC);
    479     const bool fRecordAudio =
    480         UIDataSettingsMachineDisplay::isRecordingOptionEnabled(oldDisplayData.m_strRecordingVideoOptions,
    481                                                                UIDataSettingsMachineDisplay::RecordingOption_AC);
    482     UISettingsDefs::RecordingMode enmMode;
    483     if (fRecordAudio && fRecordVideo)
    484         enmMode = UISettingsDefs::RecordingMode_VideoAudio;
    485     else if (fRecordAudio && !fRecordVideo)
    486         enmMode = UISettingsDefs::RecordingMode_AudioOnly;
    487     else
    488         enmMode = UISettingsDefs::RecordingMode_VideoOnly;
    489     m_pEditorRecordingSettings->setMode(enmMode);
    490     const int iAudioQualityRate =
    491         UIDataSettingsMachineDisplay::getAudioQualityFromOptions(oldDisplayData.m_strRecordingVideoOptions);
    492     m_pEditorRecordingSettings->setAudioQualityRate(iAudioQualityRate);
     473        if (m_pEditorVRDESettings)
     474        {
     475            m_pEditorVRDESettings->setFeatureEnabled(oldDisplayData.m_fRemoteDisplayServerEnabled);
     476            m_pEditorVRDESettings->setPort(oldDisplayData.m_strRemoteDisplayPort);
     477            m_pEditorVRDESettings->setAuthType(oldDisplayData.m_remoteDisplayAuthType);
     478            m_pEditorVRDESettings->setTimeout(QString::number(oldDisplayData.m_uRemoteDisplayTimeout));
     479            m_pEditorVRDESettings->setMultipleConnectionsAllowed(oldDisplayData.m_fRemoteDisplayMultiConnAllowed);
     480        }
     481    }
     482
     483    if (m_pEditorRecordingSettings)
     484    {
     485        /* Load old 'Recording' data from cache: */
     486        m_pEditorRecordingSettings->setFeatureEnabled(oldDisplayData.m_fRecordingEnabled);
     487        m_pEditorRecordingSettings->setFolder(oldDisplayData.m_strRecordingFolder);
     488        m_pEditorRecordingSettings->setFilePath(oldDisplayData.m_strRecordingFilePath);
     489        m_pEditorRecordingSettings->setFrameWidth(oldDisplayData.m_iRecordingVideoFrameWidth);
     490        m_pEditorRecordingSettings->setFrameHeight(oldDisplayData.m_iRecordingVideoFrameHeight);
     491        m_pEditorRecordingSettings->setFrameRate(oldDisplayData.m_iRecordingVideoFrameRate);
     492        m_pEditorRecordingSettings->setBitRate(oldDisplayData.m_iRecordingVideoBitRate);
     493        m_pEditorRecordingSettings->setScreens(oldDisplayData.m_vecRecordingScreens);
     494
     495        /* Load old 'Recording' options: */
     496        const bool fRecordVideo =
     497            UIDataSettingsMachineDisplay::isRecordingOptionEnabled(oldDisplayData.m_strRecordingVideoOptions,
     498                                                                   UIDataSettingsMachineDisplay::RecordingOption_VC);
     499        const bool fRecordAudio =
     500            UIDataSettingsMachineDisplay::isRecordingOptionEnabled(oldDisplayData.m_strRecordingVideoOptions,
     501                                                                   UIDataSettingsMachineDisplay::RecordingOption_AC);
     502        UISettingsDefs::RecordingMode enmMode;
     503        if (fRecordAudio && fRecordVideo)
     504            enmMode = UISettingsDefs::RecordingMode_VideoAudio;
     505        else if (fRecordAudio && !fRecordVideo)
     506            enmMode = UISettingsDefs::RecordingMode_AudioOnly;
     507        else
     508            enmMode = UISettingsDefs::RecordingMode_VideoOnly;
     509        m_pEditorRecordingSettings->setMode(enmMode);
     510        const int iAudioQualityRate =
     511            UIDataSettingsMachineDisplay::getAudioQualityFromOptions(oldDisplayData.m_strRecordingVideoOptions);
     512        m_pEditorRecordingSettings->setAudioQualityRate(iAudioQualityRate);
     513    }
    493514
    494515    /* Polish page finally: */
     
    501522void UIMachineSettingsDisplay::putToCache()
    502523{
    503     /* Prepare new display data: */
     524    /* Sanity check: */
     525    if (!m_pCache)
     526        return;
     527
     528    /* Prepare new data: */
    504529    UIDataSettingsMachineDisplay newDisplayData;
    505530
    506531    /* Gather new 'Screen' data: */
    507     newDisplayData.m_iCurrentVRAM = m_pEditorVideoMemorySize->value();
    508     newDisplayData.m_cGuestScreenCount = m_pEditorMonitorCount->value();
    509     newDisplayData.m_scaleFactors = m_pEditorScaleFactor->scaleFactors();
    510     newDisplayData.m_graphicsControllerType = m_pEditorGraphicsController->value();
    511 #ifdef VBOX_WITH_3D_ACCELERATION
    512     newDisplayData.m_f3dAccelerationEnabled = m_pEditorDisplayScreenFeatures->isEnabled3DAcceleration();
    513 #endif
     532    if (m_pEditorVideoMemorySize)
     533        newDisplayData.m_iCurrentVRAM = m_pEditorVideoMemorySize->value();
     534    if (m_pEditorMonitorCount)
     535        newDisplayData.m_cGuestScreenCount = m_pEditorMonitorCount->value();
     536    if (m_pEditorScaleFactor)
     537        newDisplayData.m_scaleFactors = m_pEditorScaleFactor->scaleFactors();
     538    if (m_pEditorGraphicsController)
     539        newDisplayData.m_graphicsControllerType = m_pEditorGraphicsController->value();
     540#ifdef VBOX_WITH_3D_ACCELERATION
     541    if (m_pEditorDisplayScreenFeatures)
     542        newDisplayData.m_f3dAccelerationEnabled = m_pEditorDisplayScreenFeatures->isEnabled3DAcceleration();
     543#endif
     544
    514545    /* If remote display server is supported: */
    515546    newDisplayData.m_fRemoteDisplayServerSupported = m_pCache->base().m_fRemoteDisplayServerSupported;
    516     if (newDisplayData.m_fRemoteDisplayServerSupported)
     547    if (   newDisplayData.m_fRemoteDisplayServerSupported
     548        && m_pEditorVRDESettings)
    517549    {
    518550        /* Gather new 'Remote Display' data: */
     
    524556    }
    525557
    526     /* Gather new 'Recording' data: */
    527     newDisplayData.m_fRecordingEnabled = m_pEditorRecordingSettings->isFeatureEnabled();
    528     newDisplayData.m_strRecordingFolder = m_pEditorRecordingSettings->folder();
    529     newDisplayData.m_strRecordingFilePath = m_pEditorRecordingSettings->filePath();
    530     newDisplayData.m_iRecordingVideoFrameWidth = m_pEditorRecordingSettings->frameWidth();
    531     newDisplayData.m_iRecordingVideoFrameHeight = m_pEditorRecordingSettings->frameHeight();
    532     newDisplayData.m_iRecordingVideoFrameRate = m_pEditorRecordingSettings->frameRate();
    533     newDisplayData.m_iRecordingVideoBitRate = m_pEditorRecordingSettings->bitRate();
    534     newDisplayData.m_vecRecordingScreens = m_pEditorRecordingSettings->screens();
    535 
    536     /* Gather new 'Recording' options: */
    537     const UISettingsDefs::RecordingMode enmRecordingMode = m_pEditorRecordingSettings->mode();
    538     QStringList optionValues;
    539     optionValues.append(     (enmRecordingMode == UISettingsDefs::RecordingMode_VideoAudio)
    540                           || (enmRecordingMode == UISettingsDefs::RecordingMode_VideoOnly)
    541                         ? "true" : "false");
    542     optionValues.append(     (enmRecordingMode == UISettingsDefs::RecordingMode_VideoAudio)
    543                           || (enmRecordingMode == UISettingsDefs::RecordingMode_AudioOnly)
    544                         ? "true" : "false");
    545     switch (m_pEditorRecordingSettings->audioQualityRate())
    546     {
    547         case 1: optionValues.append("low"); break;
    548         case 2: optionValues.append("med"); break;
    549         default: optionValues.append("high"); break;
    550     }
    551     QVector<UIDataSettingsMachineDisplay::RecordingOption> optionKeys;
    552     optionKeys.append(UIDataSettingsMachineDisplay::RecordingOption_VC);
    553     optionKeys.append(UIDataSettingsMachineDisplay::RecordingOption_AC);
    554     optionKeys.append(UIDataSettingsMachineDisplay::RecordingOption_AC_Profile);
    555     newDisplayData.m_strRecordingVideoOptions =
    556         UIDataSettingsMachineDisplay::setRecordingOptions(m_pCache->base().m_strRecordingVideoOptions,
    557                                                           optionKeys, optionValues);
    558 
    559     /* Cache new display data: */
     558    if (m_pEditorRecordingSettings)
     559    {
     560        /* Gather new 'Recording' data: */
     561        newDisplayData.m_fRecordingEnabled = m_pEditorRecordingSettings->isFeatureEnabled();
     562        newDisplayData.m_strRecordingFolder = m_pEditorRecordingSettings->folder();
     563        newDisplayData.m_strRecordingFilePath = m_pEditorRecordingSettings->filePath();
     564        newDisplayData.m_iRecordingVideoFrameWidth = m_pEditorRecordingSettings->frameWidth();
     565        newDisplayData.m_iRecordingVideoFrameHeight = m_pEditorRecordingSettings->frameHeight();
     566        newDisplayData.m_iRecordingVideoFrameRate = m_pEditorRecordingSettings->frameRate();
     567        newDisplayData.m_iRecordingVideoBitRate = m_pEditorRecordingSettings->bitRate();
     568        newDisplayData.m_vecRecordingScreens = m_pEditorRecordingSettings->screens();
     569
     570        /* Gather new 'Recording' options: */
     571        const UISettingsDefs::RecordingMode enmRecordingMode = m_pEditorRecordingSettings->mode();
     572        QStringList optionValues;
     573        optionValues.append(     (enmRecordingMode == UISettingsDefs::RecordingMode_VideoAudio)
     574                              || (enmRecordingMode == UISettingsDefs::RecordingMode_VideoOnly)
     575                            ? "true" : "false");
     576        optionValues.append(     (enmRecordingMode == UISettingsDefs::RecordingMode_VideoAudio)
     577                              || (enmRecordingMode == UISettingsDefs::RecordingMode_AudioOnly)
     578                            ? "true" : "false");
     579        switch (m_pEditorRecordingSettings->audioQualityRate())
     580        {
     581            case 1: optionValues.append("low"); break;
     582            case 2: optionValues.append("med"); break;
     583            default: optionValues.append("high"); break;
     584        }
     585        QVector<UIDataSettingsMachineDisplay::RecordingOption> optionKeys;
     586        optionKeys.append(UIDataSettingsMachineDisplay::RecordingOption_VC);
     587        optionKeys.append(UIDataSettingsMachineDisplay::RecordingOption_AC);
     588        optionKeys.append(UIDataSettingsMachineDisplay::RecordingOption_AC_Profile);
     589        newDisplayData.m_strRecordingVideoOptions =
     590            UIDataSettingsMachineDisplay::setRecordingOptions(m_pCache->base().m_strRecordingVideoOptions,
     591                                                              optionKeys, optionValues);
     592    }
     593
     594    /* Cache new data: */
    560595    m_pCache->cacheCurrentData(newDisplayData);
    561596}
     
    727762void UIMachineSettingsDisplay::polishPage()
    728763{
    729     /* Get old display data from cache: */
     764    /* Get old data from cache: */
    730765    const UIDataSettingsMachineDisplay &oldDisplayData = m_pCache->base();
    731766
     
    960995bool UIMachineSettingsDisplay::saveData()
    961996{
     997    /* Sanity check: */
     998    if (!m_pCache)
     999        return false;
     1000
    9621001    /* Prepare result: */
    9631002    bool fSuccess = true;
     
    9811020bool UIMachineSettingsDisplay::saveScreenData()
    9821021{
     1022    /* Sanity check: */
     1023    if (!m_pCache)
     1024        return false;
     1025
    9831026    /* Prepare result: */
    9841027    bool fSuccess = true;
     
    9861029    if (fSuccess)
    9871030    {
    988         /* Get old display data from cache: */
     1031        /* Get old data from cache: */
    9891032        const UIDataSettingsMachineDisplay &oldDisplayData = m_pCache->base();
    990         /* Get new display data from cache: */
     1033        /* Get new data from cache: */
    9911034        const UIDataSettingsMachineDisplay &newDisplayData = m_pCache->data();
    9921035
     
    10501093bool UIMachineSettingsDisplay::saveRemoteDisplayData()
    10511094{
     1095    /* Sanity check: */
     1096    if (!m_pCache)
     1097        return false;
     1098
    10521099    /* Prepare result: */
    10531100    bool fSuccess = true;
     
    10551102    if (fSuccess)
    10561103    {
    1057         /* Get old display data from cache: */
     1104        /* Get old data from cache: */
    10581105        const UIDataSettingsMachineDisplay &oldDisplayData = m_pCache->base();
    1059         /* Get new display data from cache: */
     1106        /* Get new data from cache: */
    10601107        const UIDataSettingsMachineDisplay &newDisplayData = m_pCache->data();
    10611108
     
    11131160bool UIMachineSettingsDisplay::saveRecordingData()
    11141161{
     1162    /* Sanity check: */
     1163    if (!m_pCache)
     1164        return false;
     1165
    11151166    /* Prepare result: */
    11161167    bool fSuccess = true;
     
    11181169    if (fSuccess)
    11191170    {
    1120         /* Get old display data from cache: */
     1171        /* Get old data from cache: */
    11211172        const UIDataSettingsMachineDisplay &oldDisplayData = m_pCache->base();
    1122         /* Get new display data from cache: */
     1173        /* Get new data from cache: */
    11231174        const UIDataSettingsMachineDisplay &newDisplayData = m_pCache->data();
    11241175
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsGeneral.cpp

    r94515 r94667  
    174174bool UIMachineSettingsGeneral::changed() const
    175175{
    176     return m_pCache->wasChanged();
     176    return m_pCache ? m_pCache->wasChanged() : false;
    177177}
    178178
    179179void UIMachineSettingsGeneral::loadToCacheFrom(QVariant &data)
    180180{
     181    /* Sanity check: */
     182    if (!m_pCache)
     183        return;
     184
    181185    /* Fetch data to machine: */
    182186    UISettingsPageMachine::fetchData(data);
     
    185189    m_pCache->clear();
    186190
    187     /* Prepare old general data: */
     191    /* Prepare old data: */
    188192    UIDataSettingsMachineGeneral oldGeneralData;
    189193
     
    236240    oldGeneralData.m_encryptedMedia = encryptedMedia;
    237241
    238     /* Cache old general data: */
     242    /* Cache old data: */
    239243    m_pCache->cacheInitialData(oldGeneralData);
    240244
     
    245249void UIMachineSettingsGeneral::getFromCache()
    246250{
    247     /* Get old general data from cache: */
     251    /* Sanity check: */
     252    if (!m_pCache)
     253        return;
     254
     255    /* Get old data from cache: */
    248256    const UIDataSettingsMachineGeneral &oldGeneralData = m_pCache->base();
    249257
    250258    /* Load old 'Basic' data from cache: */
    251     AssertPtrReturnVoid(m_pEditorNameAndSystem);
    252     m_pEditorNameAndSystem->setName(oldGeneralData.m_strName);
    253     m_pEditorNameAndSystem->setTypeId(oldGeneralData.m_strGuestOsTypeId);
     259    if (m_pEditorNameAndSystem)
     260    {
     261        m_pEditorNameAndSystem->setName(oldGeneralData.m_strName);
     262        m_pEditorNameAndSystem->setTypeId(oldGeneralData.m_strGuestOsTypeId);
     263    }
    254264
    255265    /* Load old 'Advanced' data from cache: */
    256     AssertPtrReturnVoid(m_pEditorSnapshotFolder);
    257     AssertPtrReturnVoid(m_pEditorClipboard);
    258     AssertPtrReturnVoid(m_pEditorDragAndDrop);
    259     m_pEditorSnapshotFolder->setPath(oldGeneralData.m_strSnapshotsFolder);
    260     m_pEditorSnapshotFolder->setInitialPath(oldGeneralData.m_strSnapshotsHomeDir);
    261     m_pEditorClipboard->setValue(oldGeneralData.m_clipboardMode);
    262     m_pEditorDragAndDrop->setValue(oldGeneralData.m_dndMode);
     266    if (m_pEditorSnapshotFolder)
     267    {
     268        m_pEditorSnapshotFolder->setPath(oldGeneralData.m_strSnapshotsFolder);
     269        m_pEditorSnapshotFolder->setInitialPath(oldGeneralData.m_strSnapshotsHomeDir);
     270    }
     271    if (m_pEditorClipboard)
     272        m_pEditorClipboard->setValue(oldGeneralData.m_clipboardMode);
     273    if (m_pEditorDragAndDrop)
     274        m_pEditorDragAndDrop->setValue(oldGeneralData.m_dndMode);
    263275
    264276    /* Load old 'Description' data from cache: */
    265     AssertPtrReturnVoid(m_pEditorDescription);
    266     m_pEditorDescription->setValue(oldGeneralData.m_strDescription);
     277    if (m_pEditorDescription)
     278        m_pEditorDescription->setValue(oldGeneralData.m_strDescription);
    267279
    268280    /* Load old 'Encryption' data from cache: */
    269     AssertPtrReturnVoid(m_pEditorDiskEncryptionSettings);
    270     m_pEditorDiskEncryptionSettings->setFeatureEnabled(oldGeneralData.m_fEncryptionEnabled);
    271     m_pEditorDiskEncryptionSettings->setCipherType(oldGeneralData.m_enmEncryptionCipherType);
    272     m_fEncryptionCipherChanged = oldGeneralData.m_fEncryptionCipherChanged;
    273     m_fEncryptionPasswordChanged = oldGeneralData.m_fEncryptionPasswordChanged;
     281    if (m_pEditorDiskEncryptionSettings)
     282    {
     283        m_pEditorDiskEncryptionSettings->setFeatureEnabled(oldGeneralData.m_fEncryptionEnabled);
     284        m_pEditorDiskEncryptionSettings->setCipherType(oldGeneralData.m_enmEncryptionCipherType);
     285    }
     286    if (m_fEncryptionCipherChanged)
     287        m_fEncryptionCipherChanged = oldGeneralData.m_fEncryptionCipherChanged;
     288    if (m_fEncryptionPasswordChanged)
     289        m_fEncryptionPasswordChanged = oldGeneralData.m_fEncryptionPasswordChanged;
    274290
    275291    /* Polish page finally: */
     
    282298void UIMachineSettingsGeneral::putToCache()
    283299{
    284     /* Prepare new general data: */
     300    /* Sanity check: */
     301    if (!m_pCache)
     302        return;
     303
     304    /* Prepare new data: */
    285305    UIDataSettingsMachineGeneral newGeneralData;
    286306
    287307    /* Gather new 'Basic' data: */
    288     AssertPtrReturnVoid(m_pEditorNameAndSystem);
    289     newGeneralData.m_strName = m_pEditorNameAndSystem->name();
    290     newGeneralData.m_strGuestOsTypeId = m_pEditorNameAndSystem->typeId();
     308    if (m_pEditorNameAndSystem)
     309    {
     310        newGeneralData.m_strName = m_pEditorNameAndSystem->name();
     311        newGeneralData.m_strGuestOsTypeId = m_pEditorNameAndSystem->typeId();
     312    }
    291313
    292314    /* Gather new 'Advanced' data: */
    293     AssertPtrReturnVoid(m_pEditorSnapshotFolder);
    294     AssertPtrReturnVoid(m_pEditorClipboard);
    295     AssertPtrReturnVoid(m_pEditorDragAndDrop);
    296     newGeneralData.m_strSnapshotsFolder = m_pEditorSnapshotFolder->path();
    297     newGeneralData.m_clipboardMode = m_pEditorClipboard->value();
    298     newGeneralData.m_dndMode = m_pEditorDragAndDrop->value();
     315    if (m_pEditorSnapshotFolder)
     316        newGeneralData.m_strSnapshotsFolder = m_pEditorSnapshotFolder->path();
     317    if (m_pEditorClipboard)
     318        newGeneralData.m_clipboardMode = m_pEditorClipboard->value();
     319    if (m_pEditorDragAndDrop)
     320        newGeneralData.m_dndMode = m_pEditorDragAndDrop->value();
    299321
    300322    /* Gather new 'Description' data: */
    301     AssertPtrReturnVoid(m_pEditorDescription);
    302     newGeneralData.m_strDescription = m_pEditorDescription->value().isEmpty() ?
    303                                      QString() : m_pEditorDescription->value();
     323    if (m_pEditorDescription)
     324        newGeneralData.m_strDescription = m_pEditorDescription->value().isEmpty()
     325                                 ? QString() : m_pEditorDescription->value();
    304326
    305327    /* Gather new 'Encryption' data: */
    306     AssertPtrReturnVoid(m_pEditorDiskEncryptionSettings);
    307     newGeneralData.m_fEncryptionEnabled = m_pEditorDiskEncryptionSettings->isFeatureEnabled();
    308     newGeneralData.m_fEncryptionCipherChanged = m_fEncryptionCipherChanged;
    309     newGeneralData.m_fEncryptionPasswordChanged = m_fEncryptionPasswordChanged;
    310     newGeneralData.m_enmEncryptionCipherType = m_pEditorDiskEncryptionSettings->cipherType();
    311     newGeneralData.m_strEncryptionPassword = m_pEditorDiskEncryptionSettings->password1();
    312     newGeneralData.m_encryptedMedia = m_pCache->base().m_encryptedMedia;
    313     /* If encryption status, cipher or password is changed: */
    314     if (newGeneralData.m_fEncryptionEnabled != m_pCache->base().m_fEncryptionEnabled ||
    315         newGeneralData.m_fEncryptionCipherChanged != m_pCache->base().m_fEncryptionCipherChanged ||
    316         newGeneralData.m_fEncryptionPasswordChanged != m_pCache->base().m_fEncryptionPasswordChanged)
    317     {
    318         /* Ask for the disk encryption passwords if necessary: */
    319         if (!m_pCache->base().m_encryptedMedia.isEmpty())
    320         {
    321             /* Create corresponding dialog: */
    322             QWidget *pDlgParent = windowManager().realParentWindow(window());
    323             QPointer<UIAddDiskEncryptionPasswordDialog> pDlg =
    324                  new UIAddDiskEncryptionPasswordDialog(pDlgParent,
    325                                                        newGeneralData.m_strName,
    326                                                        newGeneralData.m_encryptedMedia);
    327             /* Execute it and acquire the result: */
    328             if (pDlg->exec() == QDialog::Accepted)
    329                 newGeneralData.m_encryptionPasswords = pDlg->encryptionPasswords();
    330             /* Delete dialog if still valid: */
    331             if (pDlg)
    332                 delete pDlg;
    333         }
    334     }
    335 
    336     /* Cache new general data: */
     328    if (m_pEditorDiskEncryptionSettings)
     329    {
     330        newGeneralData.m_fEncryptionEnabled = m_pEditorDiskEncryptionSettings->isFeatureEnabled();
     331        newGeneralData.m_fEncryptionCipherChanged = m_fEncryptionCipherChanged;
     332        newGeneralData.m_fEncryptionPasswordChanged = m_fEncryptionPasswordChanged;
     333        newGeneralData.m_enmEncryptionCipherType = m_pEditorDiskEncryptionSettings->cipherType();
     334        newGeneralData.m_strEncryptionPassword = m_pEditorDiskEncryptionSettings->password1();
     335        newGeneralData.m_encryptedMedia = m_pCache->base().m_encryptedMedia;
     336        /* If encryption status, cipher or password is changed: */
     337        if (newGeneralData.m_fEncryptionEnabled != m_pCache->base().m_fEncryptionEnabled ||
     338            newGeneralData.m_fEncryptionCipherChanged != m_pCache->base().m_fEncryptionCipherChanged ||
     339            newGeneralData.m_fEncryptionPasswordChanged != m_pCache->base().m_fEncryptionPasswordChanged)
     340        {
     341            /* Ask for the disk encryption passwords if necessary: */
     342            if (!m_pCache->base().m_encryptedMedia.isEmpty())
     343            {
     344                /* Create corresponding dialog: */
     345                QWidget *pDlgParent = windowManager().realParentWindow(window());
     346                QPointer<UIAddDiskEncryptionPasswordDialog> pDlg =
     347                     new UIAddDiskEncryptionPasswordDialog(pDlgParent,
     348                                                           newGeneralData.m_strName,
     349                                                           newGeneralData.m_encryptedMedia);
     350                /* Execute it and acquire the result: */
     351                if (pDlg->exec() == QDialog::Accepted)
     352                    newGeneralData.m_encryptionPasswords = pDlg->encryptionPasswords();
     353                /* Delete dialog if still valid: */
     354                if (pDlg)
     355                    delete pDlg;
     356            }
     357        }
     358    }
     359
     360    /* Cache new data: */
    337361    m_pCache->cacheCurrentData(newGeneralData);
    338362}
     
    670694bool UIMachineSettingsGeneral::saveData()
    671695{
     696    /* Sanity check: */
     697    if (!m_pCache)
     698        return false;
     699
    672700    /* Prepare result: */
    673701    bool fSuccess = true;
     
    694722bool UIMachineSettingsGeneral::saveBasicData()
    695723{
     724    /* Sanity check: */
     725    if (!m_pCache)
     726        return false;
     727
    696728    /* Prepare result: */
    697729    bool fSuccess = true;
     
    699731    if (fSuccess)
    700732    {
    701         /* Get old general data from cache: */
     733        /* Get old data from cache: */
    702734        const UIDataSettingsMachineGeneral &oldGeneralData = m_pCache->base();
    703         /* Get new general data from cache: */
     735        /* Get new data from cache: */
    704736        const UIDataSettingsMachineGeneral &newGeneralData = m_pCache->data();
    705737
     
    733765bool UIMachineSettingsGeneral::saveAdvancedData()
    734766{
     767    /* Sanity check: */
     768    if (!m_pCache)
     769        return false;
     770
    735771    /* Prepare result: */
    736772    bool fSuccess = true;
     
    738774    if (fSuccess)
    739775    {
    740         /* Get old general data from cache: */
     776        /* Get old data from cache: */
    741777        const UIDataSettingsMachineGeneral &oldGeneralData = m_pCache->base();
    742         /* Get new general data from cache: */
     778        /* Get new data from cache: */
    743779        const UIDataSettingsMachineGeneral &newGeneralData = m_pCache->data();
    744780
     
    780816bool UIMachineSettingsGeneral::saveDescriptionData()
    781817{
     818    /* Sanity check: */
     819    if (!m_pCache)
     820        return false;
     821
    782822    /* Prepare result: */
    783823    bool fSuccess = true;
     
    785825    if (fSuccess)
    786826    {
    787         /* Get old general data from cache: */
     827        /* Get old data from cache: */
    788828        const UIDataSettingsMachineGeneral &oldGeneralData = m_pCache->base();
    789         /* Get new general data from cache: */
     829        /* Get new data from cache: */
    790830        const UIDataSettingsMachineGeneral &newGeneralData = m_pCache->data();
    791831
     
    807847bool UIMachineSettingsGeneral::saveEncryptionData()
    808848{
     849    /* Sanity check: */
     850    if (!m_pCache)
     851        return false;
     852
    809853    /* Prepare result: */
    810854    bool fSuccess = true;
     
    812856    if (fSuccess)
    813857    {
    814         /* Get old general data from cache: */
     858        /* Get old data from cache: */
    815859        const UIDataSettingsMachineGeneral &oldGeneralData = m_pCache->base();
    816         /* Get new general data from cache: */
     860        /* Get new data from cache: */
    817861        const UIDataSettingsMachineGeneral &newGeneralData = m_pCache->data();
    818862
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsInterface.cpp

    r94518 r94667  
    158158bool UIMachineSettingsInterface::changed() const
    159159{
    160     return m_pCache->wasChanged();
     160    return m_pCache ? m_pCache->wasChanged() : false;
    161161}
    162162
    163163void UIMachineSettingsInterface::loadToCacheFrom(QVariant &data)
    164164{
     165    /* Sanity check: */
     166    if (!m_pCache)
     167        return;
     168
    165169    /* Fetch data to machine: */
    166170    UISettingsPageMachine::fetchData(data);
     
    169173    m_pCache->clear();
    170174
    171     /* Prepare old interface data: */
     175    /* Prepare old data: */
    172176    UIDataSettingsMachineInterface oldInterfaceData;
    173177
    174     /* Gather old interface data: */
     178    /* Gather old data: */
    175179    oldInterfaceData.m_fStatusBarEnabled = gEDataManager->statusBarEnabled(m_machine.GetId());
    176180    oldInterfaceData.m_statusBarRestrictions = gEDataManager->restrictedStatusBarIndicators(m_machine.GetId());
     
    198202    oldInterfaceData.m_enmVisualState = gEDataManager->requestedVisualState(m_machine.GetId());
    199203
    200     /* Cache old interface data: */
     204    /* Cache old data: */
    201205    m_pCache->cacheInitialData(oldInterfaceData);
    202206
     
    207211void UIMachineSettingsInterface::getFromCache()
    208212{
    209     /* Get old interface data from cache: */
     213    /* Sanity check: */
     214    if (!m_pCache)
     215        return;
     216
     217    /* Get old data from cache: */
    210218    const UIDataSettingsMachineInterface &oldInterfaceData = m_pCache->base();
    211219
    212     /* Load old interface data from cache: */
    213     m_pEditorStatusBar->setStatusBarEnabled(oldInterfaceData.m_fStatusBarEnabled);
    214     m_pEditorStatusBar->setStatusBarConfiguration(oldInterfaceData.m_statusBarRestrictions,
    215                                                   oldInterfaceData.m_statusBarOrder);
    216 #ifndef VBOX_WS_MAC
    217     m_pEditorMenuBar->setMenuBarEnabled(oldInterfaceData.m_fMenuBarEnabled);
    218 #endif
    219     m_pEditorMenuBar->setRestrictionsOfMenuBar(oldInterfaceData.m_restrictionsOfMenuBar);
    220     m_pEditorMenuBar->setRestrictionsOfMenuApplication(oldInterfaceData.m_restrictionsOfMenuApplication);
    221     m_pEditorMenuBar->setRestrictionsOfMenuMachine(oldInterfaceData.m_restrictionsOfMenuMachine);
    222     m_pEditorMenuBar->setRestrictionsOfMenuView(oldInterfaceData.m_restrictionsOfMenuView);
    223     m_pEditorMenuBar->setRestrictionsOfMenuInput(oldInterfaceData.m_restrictionsOfMenuInput);
    224     m_pEditorMenuBar->setRestrictionsOfMenuDevices(oldInterfaceData.m_restrictionsOfMenuDevices);
    225 #ifdef VBOX_WITH_DEBUGGER_GUI
    226     m_pEditorMenuBar->setRestrictionsOfMenuDebug(oldInterfaceData.m_restrictionsOfMenuDebug);
    227 #endif
    228 #ifdef VBOX_WS_MAC
    229     m_pEditorMenuBar->setRestrictionsOfMenuWindow(oldInterfaceData.m_restrictionsOfMenuWindow);
    230 #endif
    231     m_pEditorMenuBar->setRestrictionsOfMenuHelp(oldInterfaceData.m_restrictionsOfMenuHelp);
    232 #ifndef VBOX_WS_MAC
    233     m_pEditorMiniToolabSettings->setShowMiniToolbar(oldInterfaceData.m_fShowMiniToolbar);
    234     m_pEditorMiniToolabSettings->setMiniToolbarAtTop(oldInterfaceData.m_fMiniToolbarAtTop);
    235 #endif
    236     m_pEditorVisualState->setMachineId(m_machine.GetId());
    237     m_pEditorVisualState->setValue(oldInterfaceData.m_enmVisualState);
     220    /* Load old data from cache: */
     221    if (m_pEditorStatusBar)
     222    {
     223        m_pEditorStatusBar->setStatusBarEnabled(oldInterfaceData.m_fStatusBarEnabled);
     224        m_pEditorStatusBar->setStatusBarConfiguration(oldInterfaceData.m_statusBarRestrictions,
     225                                                      oldInterfaceData.m_statusBarOrder);
     226    }
     227    if (m_pEditorMenuBar)
     228    {
     229#ifndef VBOX_WS_MAC
     230        m_pEditorMenuBar->setMenuBarEnabled(oldInterfaceData.m_fMenuBarEnabled);
     231#endif
     232        m_pEditorMenuBar->setRestrictionsOfMenuBar(oldInterfaceData.m_restrictionsOfMenuBar);
     233        m_pEditorMenuBar->setRestrictionsOfMenuApplication(oldInterfaceData.m_restrictionsOfMenuApplication);
     234        m_pEditorMenuBar->setRestrictionsOfMenuMachine(oldInterfaceData.m_restrictionsOfMenuMachine);
     235        m_pEditorMenuBar->setRestrictionsOfMenuView(oldInterfaceData.m_restrictionsOfMenuView);
     236        m_pEditorMenuBar->setRestrictionsOfMenuInput(oldInterfaceData.m_restrictionsOfMenuInput);
     237        m_pEditorMenuBar->setRestrictionsOfMenuDevices(oldInterfaceData.m_restrictionsOfMenuDevices);
     238#ifdef VBOX_WITH_DEBUGGER_GUI
     239        m_pEditorMenuBar->setRestrictionsOfMenuDebug(oldInterfaceData.m_restrictionsOfMenuDebug);
     240#endif
     241#ifdef VBOX_WS_MAC
     242        m_pEditorMenuBar->setRestrictionsOfMenuWindow(oldInterfaceData.m_restrictionsOfMenuWindow);
     243#endif
     244        m_pEditorMenuBar->setRestrictionsOfMenuHelp(oldInterfaceData.m_restrictionsOfMenuHelp);
     245    }
     246#ifndef VBOX_WS_MAC
     247    if (m_pEditorMiniToolabSettings)
     248    {
     249        m_pEditorMiniToolabSettings->setShowMiniToolbar(oldInterfaceData.m_fShowMiniToolbar);
     250        m_pEditorMiniToolabSettings->setMiniToolbarAtTop(oldInterfaceData.m_fMiniToolbarAtTop);
     251    }
     252#endif
     253    if (m_pEditorVisualState)
     254    {
     255        m_pEditorVisualState->setMachineId(m_machine.GetId());
     256        m_pEditorVisualState->setValue(oldInterfaceData.m_enmVisualState);
     257    }
    238258
    239259    /* Polish page finally: */
     
    246266void UIMachineSettingsInterface::putToCache()
    247267{
    248     /* Prepare new interface data: */
     268    /* Sanity check: */
     269    if (!m_pCache)
     270        return;
     271
     272    /* Prepare new data: */
    249273    UIDataSettingsMachineInterface newInterfaceData;
    250274
    251     /* Gather new interface data: */
    252     newInterfaceData.m_fStatusBarEnabled = m_pEditorStatusBar->isStatusBarEnabled();
    253     newInterfaceData.m_statusBarRestrictions = m_pEditorStatusBar->statusBarIndicatorRestrictions();
    254     newInterfaceData.m_statusBarOrder = m_pEditorStatusBar->statusBarIndicatorOrder();
    255 #ifndef VBOX_WS_MAC
    256     newInterfaceData.m_fMenuBarEnabled = m_pEditorMenuBar->isMenuBarEnabled();
    257 #endif
    258     newInterfaceData.m_restrictionsOfMenuBar = m_pEditorMenuBar->restrictionsOfMenuBar();
    259     newInterfaceData.m_restrictionsOfMenuApplication = m_pEditorMenuBar->restrictionsOfMenuApplication();
    260     newInterfaceData.m_restrictionsOfMenuMachine = m_pEditorMenuBar->restrictionsOfMenuMachine();
    261     newInterfaceData.m_restrictionsOfMenuView = m_pEditorMenuBar->restrictionsOfMenuView();
    262     newInterfaceData.m_restrictionsOfMenuInput = m_pEditorMenuBar->restrictionsOfMenuInput();
    263     newInterfaceData.m_restrictionsOfMenuDevices = m_pEditorMenuBar->restrictionsOfMenuDevices();
    264 #ifdef VBOX_WITH_DEBUGGER_GUI
    265     newInterfaceData.m_restrictionsOfMenuDebug = m_pEditorMenuBar->restrictionsOfMenuDebug();
    266 #endif
    267 #ifdef VBOX_WS_MAC
    268     newInterfaceData.m_restrictionsOfMenuWindow = m_pEditorMenuBar->restrictionsOfMenuWindow();
    269 #endif
    270     newInterfaceData.m_restrictionsOfMenuHelp = m_pEditorMenuBar->restrictionsOfMenuHelp();
    271 #ifndef VBOX_WS_MAC
    272     newInterfaceData.m_fShowMiniToolbar = m_pEditorMiniToolabSettings->showMiniToolbar();
    273     newInterfaceData.m_fMiniToolbarAtTop = m_pEditorMiniToolabSettings->miniToolbarAtTop();
    274 #endif
    275     newInterfaceData.m_enmVisualState = m_pEditorVisualState->value();
    276 
    277     /* Cache new interface data: */
     275    /* Cache new data: */
     276    if (m_pEditorStatusBar)
     277    {
     278        newInterfaceData.m_fStatusBarEnabled = m_pEditorStatusBar->isStatusBarEnabled();
     279        newInterfaceData.m_statusBarRestrictions = m_pEditorStatusBar->statusBarIndicatorRestrictions();
     280        newInterfaceData.m_statusBarOrder = m_pEditorStatusBar->statusBarIndicatorOrder();
     281    }
     282    if (m_pEditorMenuBar)
     283    {
     284#ifndef VBOX_WS_MAC
     285        newInterfaceData.m_fMenuBarEnabled = m_pEditorMenuBar->isMenuBarEnabled();
     286#endif
     287        newInterfaceData.m_restrictionsOfMenuBar = m_pEditorMenuBar->restrictionsOfMenuBar();
     288        newInterfaceData.m_restrictionsOfMenuApplication = m_pEditorMenuBar->restrictionsOfMenuApplication();
     289        newInterfaceData.m_restrictionsOfMenuMachine = m_pEditorMenuBar->restrictionsOfMenuMachine();
     290        newInterfaceData.m_restrictionsOfMenuView = m_pEditorMenuBar->restrictionsOfMenuView();
     291        newInterfaceData.m_restrictionsOfMenuInput = m_pEditorMenuBar->restrictionsOfMenuInput();
     292        newInterfaceData.m_restrictionsOfMenuDevices = m_pEditorMenuBar->restrictionsOfMenuDevices();
     293#ifdef VBOX_WITH_DEBUGGER_GUI
     294        newInterfaceData.m_restrictionsOfMenuDebug = m_pEditorMenuBar->restrictionsOfMenuDebug();
     295#endif
     296#ifdef VBOX_WS_MAC
     297        newInterfaceData.m_restrictionsOfMenuWindow = m_pEditorMenuBar->restrictionsOfMenuWindow();
     298#endif
     299        newInterfaceData.m_restrictionsOfMenuHelp = m_pEditorMenuBar->restrictionsOfMenuHelp();
     300    }
     301#ifndef VBOX_WS_MAC
     302    if (m_pEditorMiniToolabSettings)
     303    {
     304        newInterfaceData.m_fShowMiniToolbar = m_pEditorMiniToolabSettings->showMiniToolbar();
     305        newInterfaceData.m_fMiniToolbarAtTop = m_pEditorMiniToolabSettings->miniToolbarAtTop();
     306    }
     307#endif
     308    if (m_pEditorVisualState)
     309        newInterfaceData.m_enmVisualState = m_pEditorVisualState->value();
    278310    m_pCache->cacheCurrentData(newInterfaceData);
    279311}
     
    384416bool UIMachineSettingsInterface::saveData()
    385417{
     418    /* Sanity check: */
     419    if (!m_pCache)
     420        return false;
     421
    386422    /* Prepare result: */
    387423    bool fSuccess = true;
     
    408444bool UIMachineSettingsInterface::saveMenuBarData()
    409445{
     446    /* Sanity check: */
     447    if (!m_pCache)
     448        return false;
     449
    410450    /* Prepare result: */
    411451    bool fSuccess = true;
     
    413453    if (fSuccess)
    414454    {
    415         /* Get old interface data from cache: */
     455        /* Get old data from cache: */
    416456        const UIDataSettingsMachineInterface &oldInterfaceData = m_pCache->base();
    417         /* Get new interface data from cache: */
     457        /* Get new data from cache: */
    418458        const UIDataSettingsMachineInterface &newInterfaceData = m_pCache->data();
    419459
     
    461501bool UIMachineSettingsInterface::saveStatusBarData()
    462502{
     503    /* Sanity check: */
     504    if (!m_pCache)
     505        return false;
     506
    463507    /* Prepare result: */
    464508    bool fSuccess = true;
     
    466510    if (fSuccess)
    467511    {
    468         /* Get old interface data from cache: */
     512        /* Get old data from cache: */
    469513        const UIDataSettingsMachineInterface &oldInterfaceData = m_pCache->base();
    470         /* Get new interface data from cache: */
     514        /* Get new data from cache: */
    471515        const UIDataSettingsMachineInterface &newInterfaceData = m_pCache->data();
    472516
     
    487531bool UIMachineSettingsInterface::saveMiniToolbarData()
    488532{
     533    /* Sanity check: */
     534    if (!m_pCache)
     535        return false;
     536
    489537    /* Prepare result: */
    490538    bool fSuccess = true;
     
    492540    if (fSuccess)
    493541    {
    494         /* Get old interface data from cache: */
     542        /* Get old data from cache: */
    495543        const UIDataSettingsMachineInterface &oldInterfaceData = m_pCache->base(); Q_UNUSED(oldInterfaceData);
    496         /* Get new interface data from cache: */
     544        /* Get new data from cache: */
    497545        const UIDataSettingsMachineInterface &newInterfaceData = m_pCache->data(); Q_UNUSED(newInterfaceData);
    498546
     
    512560bool UIMachineSettingsInterface::saveVisualStateData()
    513561{
     562    /* Sanity check: */
     563    if (!m_pCache)
     564        return false;
     565
    514566    /* Prepare result: */
    515567    bool fSuccess = true;
     
    517569    if (fSuccess)
    518570    {
    519         /* Get old interface data from cache: */
     571        /* Get old data from cache: */
    520572        const UIDataSettingsMachineInterface &oldInterfaceData = m_pCache->base();
    521         /* Get new interface data from cache: */
     573        /* Get new data from cache: */
    522574        const UIDataSettingsMachineInterface &newInterfaceData = m_pCache->data();
    523575
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsNetwork.cpp

    r94653 r94667  
    238238void UIMachineSettingsNetwork::getAdapterDataFromCache(const UISettingsCacheMachineNetworkAdapter &adapterCache)
    239239{
    240     /* Get old adapter data: */
     240    /* Get old data: */
    241241    const UIDataSettingsMachineNetworkAdapter &oldAdapterData = adapterCache.base();
    242242
     
    284284void UIMachineSettingsNetwork::putAdapterDataToCache(UISettingsCacheMachineNetworkAdapter &adapterCache)
    285285{
    286     /* Prepare new adapter data: */
     286    /* Prepare new data: */
    287287    UIDataSettingsMachineNetworkAdapter newAdapterData;
    288288
     
    342342    }
    343343
    344     /* Cache new adapter data: */
     344    /* Cache new data: */
    345345    adapterCache.cacheCurrentData(newAdapterData);
    346346}
     
    661661#endif
    662662
    663     /* Prepare old network data: */
     663    /* Prepare old data: */
    664664    UIDataSettingsMachineNetwork oldNetworkData;
    665665
     
    667667    for (int iSlot = 0; iSlot < m_pTabWidget->count(); ++iSlot)
    668668    {
    669         /* Prepare old adapter data: */
     669        /* Prepare old data: */
    670670        UIDataSettingsMachineNetworkAdapter oldAdapterData;
    671671
     
    674674        if (!comAdapter.isNull())
    675675        {
    676             /* Gather old adapter data: */
     676            /* Gather old data: */
    677677            oldAdapterData.m_iSlot = iSlot;
    678678            oldAdapterData.m_fAdapterEnabled = comAdapter.GetEnabled();
     
    696696            foreach (const QString &strRedirect, comAdapter.GetNATEngine().GetRedirects())
    697697            {
    698                 /* Gather old forwarding data & cache key: */
     698                /* Gather old data & cache key: */
    699699                const QStringList &forwardingData = strRedirect.split(',');
    700700                AssertMsg(forwardingData.size() == 6, ("Redirect rule should be composed of 6 parts!\n"));
     
    706706                                                                 forwardingData.at(5).toUInt());
    707707                const QString &strForwardingKey = forwardingData.at(0);
    708                 /* Cache old forwarding data: */
     708                /* Cache old data: */
    709709                m_pCache->child(iSlot).child(strForwardingKey).cacheInitialData(oldForwardingData);
    710710            }
    711711        }
    712712
    713         /* Cache old adapter data: */
     713        /* Cache old data: */
    714714        m_pCache->child(iSlot).cacheInitialData(oldAdapterData);
    715715    }
    716716
    717     /* Cache old network data: */
     717    /* Cache old data: */
    718718    m_pCache->cacheInitialData(oldNetworkData);
    719719
     
    741741        AssertPtrReturnVoid(pTab);
    742742
    743         /* Load old adapter data from cache: */
     743        /* Load old data from cache: */
    744744        pTab->getAdapterDataFromCache(m_pCache->child(iSlot));
    745745
     
    765765        return;
    766766
    767     /* Prepare new network data: */
     767    /* Prepare new data: */
    768768    UIDataSettingsMachineNetwork newNetworkData;
    769769
     
    775775        AssertPtrReturnVoid(pTab);
    776776
    777         /* Gather new adapter data: */
     777        /* Gather new data: */
    778778        pTab->putAdapterDataToCache(m_pCache->child(iSlot));
    779779    }
    780780
    781     /* Cache new network data: */
     781    /* Cache new data: */
    782782    m_pCache->cacheCurrentData(newNetworkData);
    783783}
     
    11371137    if (fSuccess && m_pCache->child(iSlot).wasChanged())
    11381138    {
    1139         /* Get old network data from cache: */
     1139        /* Get old data from cache: */
    11401140        const UIDataSettingsMachineNetworkAdapter &oldAdapterData = m_pCache->child(iSlot).base();
    1141         /* Get new network data from cache: */
     1141        /* Get new data from cache: */
    11421142        const UIDataSettingsMachineNetworkAdapter &newAdapterData = m_pCache->child(iSlot).data();
    11431143
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSF.cpp

    r94333 r94667  
    320320bool UIMachineSettingsSF::changed() const
    321321{
    322     return m_pCache->wasChanged();
     322    return m_pCache ? m_pCache->wasChanged() : false;
    323323}
    324324
    325325void UIMachineSettingsSF::loadToCacheFrom(QVariant &data)
    326326{
     327    /* Sanity check: */
     328    if (!m_pCache)
     329        return;
     330
    327331    /* Fetch data to machine: */
    328332    UISettingsPageMachine::fetchData(data);
     
    331335    m_pCache->clear();
    332336
    333     /* Prepare old folders data: */
     337    /* Prepare old data: */
    334338    UIDataSettingsSharedFolders oldFoldersData;
    335339
     
    356360        for (int iFolderIndex = 0; iFolderIndex < currentTypeFolders.size(); ++iFolderIndex)
    357361        {
    358             /* Prepare old folder data & cache key: */
     362            /* Prepare old data & cache key: */
    359363            UIDataSettingsSharedFolder oldFolderData;
    360364            QString strFolderKey = QString::number(iFolderIndex);
     
    364368            if (!comFolder.isNull())
    365369            {
    366                 /* Gather old folder data: */
     370                /* Gather old data: */
    367371                oldFolderData.m_enmType = enmFolderType;
    368372                oldFolderData.m_strName = comFolder.GetName();
     
    375379            }
    376380
    377             /* Cache old folder data: */
     381            /* Cache old data: */
    378382            m_pCache->child(strFolderKey).cacheInitialData(oldFolderData);
    379383        }
    380384    }
    381385
    382     /* Cache old folders data: */
     386    /* Cache old data: */
    383387    m_pCache->cacheInitialData(oldFoldersData);
    384388
     
    389393void UIMachineSettingsSF::getFromCache()
    390394{
     395    /* Sanity check: */
     396    if (   !m_pCache
     397        || !m_pTreeWidget)
     398        return;
     399
    391400    /* Clear list initially: */
    392401    m_pTreeWidget->clear();
     
    409418void UIMachineSettingsSF::putToCache()
    410419{
    411     /* Prepare new folders data: */
     420    /* Sanity check: */
     421    if (   !m_pCache
     422        || !m_pTreeWidget)
     423        return;
     424
     425    /* Prepare new data: */
    412426    UIDataSettingsSharedFolders newFoldersData;
    413427
     
    422436        for (int iFolderIndex = 0; iFolderIndex < pFolderTypeRoot->childCount(); ++iFolderIndex)
    423437        {
    424             /* Gather and cache new folder data: */
     438            /* Gather and cache new data: */
    425439            const SFTreeViewItem *pItem = static_cast<SFTreeViewItem*>(pFolderTypeRoot->child(iFolderIndex));
    426440            m_pCache->child(pItem->m_strName).cacheCurrentData(*pItem);
     
    428442    }
    429443
    430     /* Cache new folders data: */
     444    /* Cache new data: */
    431445    m_pCache->cacheCurrentData(newFoldersData);
    432446}
     
    515529        Assert(!strName.isEmpty() && !strPath.isEmpty());
    516530
    517         /* Prepare new folder data: */
     531        /* Prepare new data: */
    518532        UIDataSettingsSharedFolder newFolderData;
    519533        newFolderData.m_enmType = enmType;
     
    10291043bool UIMachineSettingsSF::saveData()
    10301044{
     1045    /* Sanity check: */
     1046    if (!m_pCache)
     1047        return false;
     1048
    10311049    /* Prepare result: */
    10321050    bool fSuccess = true;
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSerial.cpp

    r94333 r94667  
    571571bool UIMachineSettingsSerialPage::changed() const
    572572{
    573     return m_pCache->wasChanged();
     573    return m_pCache ? m_pCache->wasChanged() : false;
    574574}
    575575
    576576void UIMachineSettingsSerialPage::loadToCacheFrom(QVariant &data)
    577577{
     578    /* Sanity check: */
     579    if (   !m_pCache
     580        || !m_pTabWidget)
     581        return;
     582
    578583    /* Fetch data to machine: */
    579584    UISettingsPageMachine::fetchData(data);
     
    582587    m_pCache->clear();
    583588
    584     /* Prepare old serial data: */
     589    /* Prepare old data: */
    585590    UIDataSettingsMachineSerial oldSerialData;
    586591
     
    588593    for (int iSlot = 0; iSlot < m_pTabWidget->count(); ++iSlot)
    589594    {
    590         /* Prepare old port data: */
     595        /* Prepare old data: */
    591596        UIDataSettingsMachineSerialPort oldPortData;
    592597
     
    595600        if (!comPort.isNull())
    596601        {
    597             /* Gather old port data: */
     602            /* Gather old data: */
    598603            oldPortData.m_iSlot = iSlot;
    599604            oldPortData.m_fPortEnabled = comPort.GetEnabled();
     
    605610        }
    606611
    607         /* Cache old port data: */
     612        /* Cache old data: */
    608613        m_pCache->child(iSlot).cacheInitialData(oldPortData);
    609614    }
    610615
    611     /* Cache old serial data: */
     616    /* Cache old data: */
    612617    m_pCache->cacheInitialData(oldSerialData);
    613618
     
    618623void UIMachineSettingsSerialPage::getFromCache()
    619624{
     625    /* Sanity check: */
     626    if (   !m_pCache
     627        || !m_pTabWidget)
     628        return;
     629
    620630    /* Setup tab order: */
    621631    AssertPtrReturnVoid(firstWidget());
     
    627637    {
    628638        /* Get port page: */
    629         UIMachineSettingsSerial *pPage = qobject_cast<UIMachineSettingsSerial*>(m_pTabWidget->widget(iSlot));
    630 
    631         /* Load old port data from cache: */
    632         pPage->loadPortData(m_pCache->child(iSlot).base());
     639        UIMachineSettingsSerial *pTab = qobject_cast<UIMachineSettingsSerial*>(m_pTabWidget->widget(iSlot));
     640        AssertPtrReturnVoid(pTab);
     641
     642        /* Load old data from cache: */
     643        pTab->loadPortData(m_pCache->child(iSlot).base());
    633644
    634645        /* Setup tab order: */
    635         pLastFocusWidget = pPage->setOrderAfter(pLastFocusWidget);
     646        pLastFocusWidget = pTab->setOrderAfter(pLastFocusWidget);
    636647    }
    637648
     
    648659void UIMachineSettingsSerialPage::putToCache()
    649660{
    650     /* Prepare new serial data: */
     661    /* Sanity check: */
     662    if (   !m_pCache
     663        || !m_pTabWidget)
     664        return;
     665
     666    /* Prepare new data: */
    651667    UIDataSettingsMachineSerial newSerialData;
    652668
     
    656672        /* Getting port page: */
    657673        UIMachineSettingsSerial *pTab = qobject_cast<UIMachineSettingsSerial*>(m_pTabWidget->widget(iSlot));
    658 
    659         /* Prepare new port data: */
     674        AssertPtrReturnVoid(pTab);
     675
     676        /* Prepare new data: */
    660677        UIDataSettingsMachineSerialPort newPortData;
    661678
    662         /* Gather new port data: */
     679        /* Gather new data: */
    663680        pTab->savePortData(newPortData);
    664681
    665         /* Cache new port data: */
     682        /* Cache new data: */
    666683        m_pCache->child(iSlot).cacheCurrentData(newPortData);
    667684    }
    668685
    669     /* Cache new serial data: */
     686    /* Cache new data: */
    670687    m_pCache->cacheCurrentData(newSerialData);
    671688}
     
    777794                                     m_pCache->child(iSlot).base().m_fPortEnabled));
    778795        UIMachineSettingsSerial *pTab = qobject_cast<UIMachineSettingsSerial*>(m_pTabWidget->widget(iSlot));
     796        AssertPtrReturnVoid(pTab);
    779797        pTab->polishTab();
    780798    }
     
    825843bool UIMachineSettingsSerialPage::saveData()
    826844{
     845    /* Sanity check: */
     846    if (   !m_pCache
     847        || !m_pTabWidget)
     848        return false;
     849
    827850    /* Prepare result: */
    828851    bool fSuccess = true;
     
    840863bool UIMachineSettingsSerialPage::savePortData(int iSlot)
    841864{
     865    /* Sanity check: */
     866    if (!m_pCache)
     867        return false;
     868
    842869    /* Prepare result: */
    843870    bool fSuccess = true;
     
    845872    if (fSuccess && m_pCache->child(iSlot).wasChanged())
    846873    {
    847         /* Get old serial data from cache: */
     874        /* Get old data from cache: */
    848875        const UIDataSettingsMachineSerialPort &oldPortData = m_pCache->child(iSlot).base();
    849         /* Get new serial data from cache: */
     876        /* Get new data from cache: */
    850877        const UIDataSettingsMachineSerialPort &newPortData = m_pCache->child(iSlot).data();
    851878
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsStorage.cpp

    r94394 r94667  
    30323032bool UIMachineSettingsStorage::changed() const
    30333033{
    3034     return m_pCache->wasChanged();
     3034    return m_pCache ? m_pCache->wasChanged() : false;
    30353035}
    30363036
    30373037void UIMachineSettingsStorage::loadToCacheFrom(QVariant &data)
    30383038{
     3039    /* Sanity check: */
     3040    if (!m_pCache)
     3041        return;
     3042
    30393043    /* Fetch data to machine: */
    30403044    UISettingsPageMachine::fetchData(data);
     
    30433047    m_pCache->clear();
    30443048
    3045     /* Prepare old storage data: */
     3049    /* Prepare old data: */
    30463050    UIDataSettingsMachineStorage oldStorageData;
    30473051
    3048     /* Gather old common data: */
     3052    /* Gather old data: */
    30493053    m_uMachineId = m_machine.GetId();
    30503054    m_strMachineSettingsFilePath = m_machine.GetSettingsFilePath();
     
    30563060    for (int iControllerIndex = 0; iControllerIndex < controllers.size(); ++iControllerIndex)
    30573061    {
    3058         /* Prepare old controller data & cache key: */
     3062        /* Prepare old data & cache key: */
    30593063        UIDataSettingsMachineStorageController oldControllerData;
    30603064        QString strControllerKey = QString::number(iControllerIndex);
     
    30643068        if (!comController.isNull())
    30653069        {
    3066             /* Gather old controller data: */
     3070            /* Gather old data: */
    30673071            oldControllerData.m_strName = comController.GetName();
    30683072            oldControllerData.m_enmBus = comController.GetBus();
     
    30883092            for (int iAttachmentIndex = 0; iAttachmentIndex < attachments.size(); ++iAttachmentIndex)
    30893093            {
    3090                 /* Prepare old attachment data & cache key: */
     3094                /* Prepare old data & cache key: */
    30913095                UIDataSettingsMachineStorageAttachment oldAttachmentData;
    30923096                QString strAttachmentKey = QString::number(iAttachmentIndex);
     
    30963100                if (!comAttachment.isNull())
    30973101                {
    3098                     /* Gather old attachment data: */
     3102                    /* Gather old data: */
    30993103                    oldAttachmentData.m_enmDeviceType = comAttachment.GetType();
    31003104                    oldAttachmentData.m_iPort = comAttachment.GetPort();
     
    31103114                }
    31113115
    3112                 /* Cache old attachment data: */
     3116                /* Cache old data: */
    31133117                m_pCache->child(strControllerKey).child(strAttachmentKey).cacheInitialData(oldAttachmentData);
    31143118            }
    31153119        }
    31163120
    3117         /* Cache old controller data: */
     3121        /* Cache old data: */
    31183122        m_pCache->child(strControllerKey).cacheInitialData(oldControllerData);
    31193123    }
    31203124
    3121     /* Cache old storage data: */
     3125    /* Cache old data: */
    31223126    m_pCache->cacheInitialData(oldStorageData);
    31233127
     
    31283132void UIMachineSettingsStorage::getFromCache()
    31293133{
     3134    /* Sanity check: */
     3135    if (   !m_pCache
     3136        || !m_pModelStorage
     3137        || !m_pTreeViewStorage)
     3138        return;
     3139
    31303140    /* Clear model initially: */
    31313141    m_pModelStorage->clear();
    31323142
    3133     /* Load old common data from cache: */
     3143    /* Load old data from cache: */
    31343144    m_pModelStorage->setMachineId(m_uMachineId);
    31353145
     
    31393149        /* Get controller cache: */
    31403150        const UISettingsCacheMachineStorageController &controllerCache = m_pCache->child(iControllerIndex);
    3141         /* Get old controller data from cache: */
     3151        /* Get old data from cache: */
    31423152        const UIDataSettingsMachineStorageController &oldControllerData = controllerCache.base();
    31433153
    3144         /* Load old controller data from cache: */
     3154        /* Load old data from cache: */
    31453155        const QModelIndex controllerIndex = m_pModelStorage->addController(oldControllerData.m_strName,
    31463156                                                                           oldControllerData.m_enmBus,
     
    31553165            /* Get attachment cache: */
    31563166            const UISettingsCacheMachineStorageAttachment &attachmentCache = controllerCache.child(iAttachmentIndex);
    3157             /* Get old attachment data from cache: */
     3167            /* Get old data from cache: */
    31583168            const UIDataSettingsMachineStorageAttachment &oldAttachmentData = attachmentCache.base();
    31593169
    3160             /* Load old attachment data from cache: */
     3170            /* Load old data from cache: */
    31613171            const QModelIndex attachmentIndex = m_pModelStorage->addAttachment(controllerId,
    31623172                                                                               oldAttachmentData.m_enmDeviceType,
     
    31893199void UIMachineSettingsStorage::putToCache()
    31903200{
    3191     /* Prepare new storage data: */
     3201    /* Sanity check: */
     3202    if (   !m_pCache
     3203        || !m_pModelStorage)
     3204        return;
     3205
     3206    /* Prepare new data: */
    31923207    UIDataSettingsMachineStorage newStorageData;
    31933208
     
    31963211    for (int iControllerIndex = 0; iControllerIndex < m_pModelStorage->rowCount(rootIndex); ++iControllerIndex)
    31973212    {
    3198         /* Prepare new controller data & key: */
     3213        /* Prepare new data & key: */
    31993214        UIDataSettingsMachineStorageController newControllerData;
    32003215
    3201         /* Gather new controller data & cache key from model: */
     3216        /* Gather new data & cache key from model: */
    32023217        const QModelIndex controllerIndex = m_pModelStorage->index(iControllerIndex, 0, rootIndex);
    32033218        newControllerData.m_strName = m_pModelStorage->data(controllerIndex, StorageModel::R_CtrName).toString();
     
    32113226        for (int iAttachmentIndex = 0; iAttachmentIndex < m_pModelStorage->rowCount(controllerIndex); ++iAttachmentIndex)
    32123227        {
    3213             /* Prepare new attachment data & key: */
     3228            /* Prepare new data & key: */
    32143229            UIDataSettingsMachineStorageAttachment newAttachmentData;
    32153230
    3216             /* Gather new attachment data & cache key from model: */
     3231            /* Gather new data & cache key from model: */
    32173232            const QModelIndex attachmentIndex = m_pModelStorage->index(iAttachmentIndex, 0, controllerIndex);
    32183233            newAttachmentData.m_enmDeviceType = m_pModelStorage->data(attachmentIndex, StorageModel::R_AttDevice).value<KDeviceType>();
     
    32273242            const QString strAttachmentKey = QString("%1:%2").arg(newAttachmentData.m_iPort).arg(newAttachmentData.m_iDevice);
    32283243
    3229             /* Cache new attachment data: */
     3244            /* Cache new data: */
    32303245            m_pCache->child(strControllerKey).child(strAttachmentKey).cacheCurrentData(newAttachmentData);
    32313246        }
    32323247
    3233         /* Cache new controller data: */
     3248        /* Cache new data: */
    32343249        m_pCache->child(strControllerKey).cacheCurrentData(newControllerData);
    32353250    }
    32363251
    3237     /* Cache new storage data: */
     3252    /* Cache new data: */
    32383253    m_pCache->cacheCurrentData(newStorageData);
    32393254}
     
    53815396bool UIMachineSettingsStorage::saveData()
    53825397{
     5398    /* Sanity check: */
     5399    if (!m_pCache)
     5400        return false;
     5401
    53835402    /* Prepare result: */
    53845403    bool fSuccess = true;
     
    54455464    if (fSuccess && isMachineOffline())
    54465465    {
    5447         /* Get old controller data from cache: */
     5466        /* Get old data from cache: */
    54485467        const UIDataSettingsMachineStorageController &oldControllerData = controllerCache.base();
    54495468
     
    54755494    if (fSuccess && isMachineOffline())
    54765495    {
    5477         /* Get new controller data from cache: */
     5496        /* Get new data from cache: */
    54785497        const UIDataSettingsMachineStorageController &newControllerData = controllerCache.data();
    54795498
     
    55625581    if (fSuccess)
    55635582    {
    5564         /* Get old controller data from cache: */
     5583        /* Get old data from cache: */
    55655584        const UIDataSettingsMachineStorageController &oldControllerData = controllerCache.base();
    5566         /* Get new controller data from cache: */
     5585        /* Get new data from cache: */
    55675586        const UIDataSettingsMachineStorageController &newControllerData = controllerCache.data();
    55685587
     
    56665685    if (fSuccess)
    56675686    {
    5668         /* Get old controller data from cache: */
     5687        /* Get old data from cache: */
    56695688        const UIDataSettingsMachineStorageController &oldControllerData = controllerCache.base();
    5670         /* Get old attachment data from cache: */
     5689        /* Get old data from cache: */
    56715690        const UIDataSettingsMachineStorageAttachment &oldAttachmentData = attachmentCache.base();
    56725691
     
    57035722    if (fSuccess)
    57045723    {
    5705         /* Get new controller data from cache: */
     5724        /* Get new data from cache: */
    57065725        const UIDataSettingsMachineStorageController &newControllerData = controllerCache.data();
    5707         /* Get new attachment data from cache: */
     5726        /* Get new data from cache: */
    57085727        const UIDataSettingsMachineStorageAttachment &newAttachmentData = attachmentCache.data();
    57095728
     
    57935812    if (fSuccess)
    57945813    {
    5795         /* Get new controller data from cache: */
     5814        /* Get new data from cache: */
    57965815        const UIDataSettingsMachineStorageController &newControllerData = controllerCache.data();
    5797         /* Get new attachment data from cache: */
     5816        /* Get new data from cache: */
    57985817        const UIDataSettingsMachineStorageAttachment &newAttachmentData = attachmentCache.data();
    57995818
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSystem.cpp

    r94333 r94667  
    257257bool UIMachineSettingsSystem::changed() const
    258258{
    259     return m_pCache->wasChanged();
     259    return m_pCache ? m_pCache->wasChanged() : false;
    260260}
    261261
    262262void UIMachineSettingsSystem::loadToCacheFrom(QVariant &data)
    263263{
     264    /* Sanity check: */
     265    if (!m_pCache)
     266        return;
     267
    264268    /* Fetch data to machine: */
    265269    UISettingsPageMachine::fetchData(data);
     
    268272    m_pCache->clear();
    269273
    270     /* Prepare old system data: */
     274    /* Prepare old data: */
    271275    UIDataSettingsMachineSystem oldSystemData;
    272276
     
    297301    oldSystemData.m_fEnabledNestedPaging = m_machine.GetHWVirtExProperty(KHWVirtExPropertyType_NestedPaging);
    298302
    299     /* Cache old system data: */
     303    /* Cache old data: */
    300304    m_pCache->cacheInitialData(oldSystemData);
    301305
     
    306310void UIMachineSettingsSystem::getFromCache()
    307311{
    308     /* Get old system data from cache: */
     312    /* Sanity check: */
     313    if (!m_pCache)
     314        return;
     315
     316    /* Get old data from cache: */
    309317    const UIDataSettingsMachineSystem &oldSystemData = m_pCache->base();
    310318
     
    316324
    317325    /* Load old 'Motherboard' data from cache: */
    318     m_pEditorBaseMemory->setValue(oldSystemData.m_iMemorySize);
    319     m_pEditorBootOrder->setValue(oldSystemData.m_bootItems);
    320     const int iChipsetTypePosition = m_pComboChipset->findData(oldSystemData.m_chipsetType);
    321     m_pComboChipset->setCurrentIndex(iChipsetTypePosition == -1 ? 0 : iChipsetTypePosition);
    322     const int iHIDTypePosition = m_pComboPointingHID->findData(oldSystemData.m_pointingHIDType);
    323     m_pComboPointingHID->setCurrentIndex(iHIDTypePosition == -1 ? 0 : iHIDTypePosition);
    324     m_pCheckBoxAPIC->setChecked(oldSystemData.m_fEnabledIoApic);
    325     m_pCheckBoxEFI->setChecked(oldSystemData.m_fEnabledEFI);
    326     m_pCheckBoxUTC->setChecked(oldSystemData.m_fEnabledUTC);
     326    if (m_pEditorBaseMemory)
     327        m_pEditorBaseMemory->setValue(oldSystemData.m_iMemorySize);
     328    if (m_pEditorBootOrder)
     329        m_pEditorBootOrder->setValue(oldSystemData.m_bootItems);
     330    if (m_pComboChipset)
     331    {
     332        const int iChipsetTypePosition = m_pComboChipset->findData(oldSystemData.m_chipsetType);
     333        m_pComboChipset->setCurrentIndex(iChipsetTypePosition == -1 ? 0 : iChipsetTypePosition);
     334    }
     335    if (m_pComboPointingHID)
     336    {
     337        const int iHIDTypePosition = m_pComboPointingHID->findData(oldSystemData.m_pointingHIDType);
     338        m_pComboPointingHID->setCurrentIndex(iHIDTypePosition == -1 ? 0 : iHIDTypePosition);
     339    }
     340    if (m_pCheckBoxAPIC)
     341        m_pCheckBoxAPIC->setChecked(oldSystemData.m_fEnabledIoApic);
     342    if (m_pCheckBoxEFI)
     343        m_pCheckBoxEFI->setChecked(oldSystemData.m_fEnabledEFI);
     344    if (m_pCheckBoxUTC)
     345        m_pCheckBoxUTC->setChecked(oldSystemData.m_fEnabledUTC);
    327346
    328347    /* Load old 'Processor' data from cache: */
    329     m_pSliderProcessorCount->setValue(oldSystemData.m_cCPUCount);
    330     m_pSliderProcessorExecCap->setValue(oldSystemData.m_iCPUExecCap);
    331     m_pCheckBoxPAE->setChecked(oldSystemData.m_fEnabledPAE);
    332     m_pCheckBoxNestedVirtualization->setChecked(oldSystemData.m_fEnabledNestedHwVirtEx);
     348    if (m_pSliderProcessorCount)
     349        m_pSliderProcessorCount->setValue(oldSystemData.m_cCPUCount);
     350    if (m_pSliderProcessorExecCap)
     351        m_pSliderProcessorExecCap->setValue(oldSystemData.m_iCPUExecCap);
     352    if (m_pCheckBoxPAE)
     353        m_pCheckBoxPAE->setChecked(oldSystemData.m_fEnabledPAE);
     354    if (m_pCheckBoxNestedVirtualization)
     355        m_pCheckBoxNestedVirtualization->setChecked(oldSystemData.m_fEnabledNestedHwVirtEx);
    333356
    334357    /* Load old 'Acceleration' data from cache: */
    335     const int iParavirtProviderPosition = m_pComboParavirtProvider->findData(oldSystemData.m_paravirtProvider);
    336     m_pComboParavirtProvider->setCurrentIndex(iParavirtProviderPosition == -1 ? 0 : iParavirtProviderPosition);
    337     m_pCheckBoxVirtualization->setChecked(oldSystemData.m_fEnabledHwVirtEx);
    338     m_pCheckBoxNestedPaging->setChecked(oldSystemData.m_fEnabledNestedPaging);
     358    if (m_pComboParavirtProvider)
     359    {
     360        const int iParavirtProviderPosition = m_pComboParavirtProvider->findData(oldSystemData.m_paravirtProvider);
     361        m_pComboParavirtProvider->setCurrentIndex(iParavirtProviderPosition == -1 ? 0 : iParavirtProviderPosition);
     362    }
     363    if (m_pCheckBoxVirtualization)
     364        m_pCheckBoxVirtualization->setChecked(oldSystemData.m_fEnabledHwVirtEx);
     365    if (m_pCheckBoxNestedPaging)
     366        m_pCheckBoxNestedPaging->setChecked(oldSystemData.m_fEnabledNestedPaging);
    339367
    340368    /* Polish page finally: */
     
    347375void UIMachineSettingsSystem::putToCache()
    348376{
    349     /* Prepare new system data: */
     377    /* Sanity check: */
     378    if (!m_pCache)
     379        return;
     380
     381    /* Prepare new data: */
    350382    UIDataSettingsMachineSystem newSystemData;
    351383
     
    357389
    358390    /* Gather 'Motherboard' data: */
    359     newSystemData.m_iMemorySize = m_pEditorBaseMemory->value();
    360     newSystemData.m_bootItems = m_pEditorBootOrder->value();
    361     newSystemData.m_chipsetType = m_pComboChipset->currentData().value<KChipsetType>();
    362     newSystemData.m_pointingHIDType = m_pComboPointingHID->currentData().value<KPointingHIDType>();
    363     newSystemData.m_fEnabledIoApic =    m_pCheckBoxAPIC->isChecked()
    364                                      || m_pSliderProcessorCount->value() > 1
    365                                      || m_pComboChipset->currentData().value<KChipsetType>() == KChipsetType_ICH9;
    366     newSystemData.m_fEnabledEFI = m_pCheckBoxEFI->isChecked();
    367     newSystemData.m_fEnabledUTC = m_pCheckBoxUTC->isChecked();
     391    if (m_pEditorBaseMemory)
     392        newSystemData.m_iMemorySize = m_pEditorBaseMemory->value();
     393    if (m_pEditorBootOrder)
     394        newSystemData.m_bootItems = m_pEditorBootOrder->value();
     395    if (m_pComboChipset)
     396        newSystemData.m_chipsetType = m_pComboChipset->currentData().value<KChipsetType>();
     397    if (m_pComboPointingHID)
     398        newSystemData.m_pointingHIDType = m_pComboPointingHID->currentData().value<KPointingHIDType>();
     399    if (   m_pCheckBoxAPIC
     400        && m_pSliderProcessorCount
     401        && m_pComboChipset)
     402        newSystemData.m_fEnabledIoApic =    m_pCheckBoxAPIC->isChecked()
     403                                         || m_pSliderProcessorCount->value() > 1
     404                                         || m_pComboChipset->currentData().value<KChipsetType>() == KChipsetType_ICH9;
     405    if (m_pCheckBoxEFI)
     406        newSystemData.m_fEnabledEFI = m_pCheckBoxEFI->isChecked();
     407    if (m_pCheckBoxUTC)
     408        newSystemData.m_fEnabledUTC = m_pCheckBoxUTC->isChecked();
    368409
    369410    /* Gather 'Processor' data: */
    370     newSystemData.m_cCPUCount = m_pSliderProcessorCount->value();
    371     newSystemData.m_iCPUExecCap = m_pSliderProcessorExecCap->value();
    372     newSystemData.m_fEnabledPAE = m_pCheckBoxPAE->isChecked();
     411    if (m_pSliderProcessorCount)
     412        newSystemData.m_cCPUCount = m_pSliderProcessorCount->value();
     413    if (m_pSliderProcessorExecCap)
     414        newSystemData.m_iCPUExecCap = m_pSliderProcessorExecCap->value();
     415    if (m_pCheckBoxPAE)
     416        newSystemData.m_fEnabledPAE = m_pCheckBoxPAE->isChecked();
    373417    newSystemData.m_fEnabledNestedHwVirtEx = isNestedHWVirtExEnabled();
    374418
    375419    /* Gather 'Acceleration' data: */
    376     newSystemData.m_paravirtProvider = m_pComboParavirtProvider->currentData().value<KParavirtProvider>();
     420    if (m_pComboParavirtProvider)
     421        newSystemData.m_paravirtProvider = m_pComboParavirtProvider->currentData().value<KParavirtProvider>();
    377422    /* Enable HW Virt Ex automatically if it's supported and
    378423     * 1. multiple CPUs, 2. Nested Paging or 3. Nested HW Virt Ex is requested. */
    379     newSystemData.m_fEnabledHwVirtEx =    isHWVirtExEnabled()
    380                                        || (   isHWVirtExSupported()
    381                                            && (   m_pSliderProcessorCount->value() > 1
    382                                                || isNestedPagingEnabled()
    383                                                || isNestedHWVirtExEnabled()));
     424    if (m_pSliderProcessorCount)
     425        newSystemData.m_fEnabledHwVirtEx =    isHWVirtExEnabled()
     426                                           || (   isHWVirtExSupported()
     427                                               && (   m_pSliderProcessorCount->value() > 1
     428                                                   || isNestedPagingEnabled()
     429                                                   || isNestedHWVirtExEnabled()));
    384430    /* Enable Nested Paging automatically if it's supported and
    385431     * Nested HW Virt Ex is requested. */
    386432    newSystemData.m_fEnabledNestedPaging =    isNestedPagingEnabled()
    387                                            || (   isNestedPagingSupported()
    388                                                && isNestedHWVirtExEnabled());
    389 
    390     /* Cache new system data: */
     433                                     || (   isNestedPagingSupported()
     434                                         && isNestedHWVirtExEnabled());
     435
     436    /* Cache new data: */
    391437    m_pCache->cacheCurrentData(newSystemData);
    392438}
     
    686732void UIMachineSettingsSystem::polishPage()
    687733{
    688     /* Get old system data from cache: */
     734    /* Get old data from cache: */
    689735    const UIDataSettingsMachineSystem &systemData = m_pCache->base();
    690736
     
    13201366bool UIMachineSettingsSystem::saveData()
    13211367{
     1368    /* Sanity check: */
     1369    if (!m_pCache)
     1370        return false;
     1371
    13221372    /* Prepare result: */
    13231373    bool fSuccess = true;
     
    13411391bool UIMachineSettingsSystem::saveMotherboardData()
    13421392{
     1393    /* Sanity check: */
     1394    if (!m_pCache)
     1395        return false;
     1396
    13431397    /* Prepare result: */
    13441398    bool fSuccess = true;
     
    13461400    if (fSuccess)
    13471401    {
    1348         /* Get old system data from cache: */
     1402        /* Get old data from cache: */
    13491403        const UIDataSettingsMachineSystem &oldSystemData = m_pCache->base();
    1350         /* Get new system data from cache: */
     1404        /* Get new data from cache: */
    13511405        const UIDataSettingsMachineSystem &newSystemData = m_pCache->data();
    13521406
     
    14041458bool UIMachineSettingsSystem::saveProcessorData()
    14051459{
     1460    /* Sanity check: */
     1461    if (!m_pCache)
     1462        return false;
     1463
    14061464    /* Prepare result: */
    14071465    bool fSuccess = true;
     
    14091467    if (fSuccess)
    14101468    {
    1411         /* Get old system data from cache: */
     1469        /* Get old data from cache: */
    14121470        const UIDataSettingsMachineSystem &oldSystemData = m_pCache->base();
    1413         /* Get new system data from cache: */
     1471        /* Get new data from cache: */
    14141472        const UIDataSettingsMachineSystem &newSystemData = m_pCache->data();
    14151473
     
    14491507bool UIMachineSettingsSystem::saveAccelerationData()
    14501508{
     1509    /* Sanity check: */
     1510    if (!m_pCache)
     1511        return false;
     1512
    14511513    /* Prepare result: */
    14521514    bool fSuccess = true;
     
    14541516    if (fSuccess)
    14551517    {
    1456         /* Get old system data from cache: */
     1518        /* Get old data from cache: */
    14571519        const UIDataSettingsMachineSystem &oldSystemData = m_pCache->base();
    1458         /* Get new system data from cache: */
     1520        /* Get new data from cache: */
    14591521        const UIDataSettingsMachineSystem &newSystemData = m_pCache->data();
    14601522
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsUSB.cpp

    r94333 r94667  
    369369bool UIMachineSettingsUSB::changed() const
    370370{
    371     return m_pCache->wasChanged();
     371    return m_pCache ? m_pCache->wasChanged() : false;
    372372}
    373373
    374374void UIMachineSettingsUSB::loadToCacheFrom(QVariant &data)
    375375{
     376    /* Sanity check: */
     377    if (!m_pCache)
     378        return;
     379
    376380    /* Fetch data to machine: */
    377381    UISettingsPageMachine::fetchData(data);
     
    398402        for (int iFilterIndex = 0; iFilterIndex < filters.size(); ++iFilterIndex)
    399403        {
    400             /* Prepare old filter data: */
     404            /* Prepare old data: */
    401405            UIDataSettingsMachineUSBFilter oldFilterData;
    402406
     
    405409            if (!filter.isNull())
    406410            {
    407                 /* Gather old filter data: */
     411                /* Gather old data: */
    408412                oldFilterData.m_fActive = filter.GetActive();
    409413                oldFilterData.m_strName = filter.GetName();
     
    418422            }
    419423
    420             /* Cache old filter data: */
     424            /* Cache old data: */
    421425            m_pCache->child(iFilterIndex).cacheInitialData(oldFilterData);
    422426        }
     
    432436void UIMachineSettingsUSB::getFromCache()
    433437{
     438    /* Sanity check: */
     439    if (   !m_pCache
     440        || !m_pTreeWidgetFilters)
     441        return;
     442
    434443    /* Clear list initially: */
    435444    m_pTreeWidgetFilters->clear();
     
    446455
    447456    /* Adjust radio-button visibility: */
    448     m_pRadioButtonUSB1->setVisible(supportedTypes.contains(KUSBControllerType_OHCI));
    449     m_pRadioButtonUSB2->setVisible(supportedTypes.contains(KUSBControllerType_EHCI));
    450     m_pRadioButtonUSB3->setVisible(supportedTypes.contains(KUSBControllerType_XHCI));
     457    if (m_pRadioButtonUSB1)
     458        m_pRadioButtonUSB1->setVisible(supportedTypes.contains(KUSBControllerType_OHCI));
     459    if (m_pRadioButtonUSB2)
     460        m_pRadioButtonUSB2->setVisible(supportedTypes.contains(KUSBControllerType_EHCI));
     461    if (m_pRadioButtonUSB3)
     462        m_pRadioButtonUSB3->setVisible(supportedTypes.contains(KUSBControllerType_XHCI));
    451463
    452464    /* Load old USB data from cache: */
    453     m_pCheckBoxUSB->setChecked(oldUsbData.m_fUSBEnabled);
     465    if (m_pCheckBoxUSB)
     466        m_pCheckBoxUSB->setChecked(oldUsbData.m_fUSBEnabled);
    454467    switch (oldUsbData.m_USBControllerType)
    455468    {
    456469        default:
    457         case KUSBControllerType_OHCI: m_pRadioButtonUSB1->setChecked(true); break;
    458         case KUSBControllerType_EHCI: m_pRadioButtonUSB2->setChecked(true); break;
    459         case KUSBControllerType_XHCI: m_pRadioButtonUSB3->setChecked(true); break;
     470        case KUSBControllerType_OHCI:
     471        {
     472            if (m_pRadioButtonUSB1)
     473                m_pRadioButtonUSB1->setChecked(true);
     474            break;
     475        }
     476        case KUSBControllerType_EHCI:
     477        {
     478            if (m_pRadioButtonUSB2)
     479                m_pRadioButtonUSB2->setChecked(true);
     480            break;
     481        }
     482        case KUSBControllerType_XHCI:
     483        {
     484            if (m_pRadioButtonUSB3)
     485                m_pRadioButtonUSB3->setChecked(true);
     486            break;
     487        }
    460488    }
    461489
     
    466494    /* Choose first filter as current: */
    467495    m_pTreeWidgetFilters->setCurrentItem(m_pTreeWidgetFilters->topLevelItem(0));
    468     sltHandleUsbAdapterToggle(m_pCheckBoxUSB->isChecked());
     496    if (m_pCheckBoxUSB)
     497        sltHandleUsbAdapterToggle(m_pCheckBoxUSB->isChecked());
    469498
    470499    /* Polish page finally: */
     
    477506void UIMachineSettingsUSB::putToCache()
    478507{
     508    /* Sanity check: */
     509    if (   !m_pCache
     510        || !m_pTreeWidgetFilters)
     511        return;
     512
    479513    /* Prepare new USB data: */
    480514    UIDataSettingsMachineUSB newUsbData;
    481515
    482516    /* Gather new USB data: */
    483     newUsbData.m_fUSBEnabled = m_pCheckBoxUSB->isChecked();
     517    if (m_pCheckBoxUSB)
     518        newUsbData.m_fUSBEnabled = m_pCheckBoxUSB->isChecked();
    484519    if (!newUsbData.m_fUSBEnabled)
    485520        newUsbData.m_USBControllerType = KUSBControllerType_Null;
    486521    else
    487522    {
    488         if (m_pRadioButtonUSB1->isChecked())
     523        if (   m_pRadioButtonUSB1
     524            && m_pRadioButtonUSB1->isChecked())
    489525            newUsbData.m_USBControllerType = KUSBControllerType_OHCI;
    490         else if (m_pRadioButtonUSB2->isChecked())
     526        else if (   m_pRadioButtonUSB2
     527                 && m_pRadioButtonUSB2->isChecked())
    491528            newUsbData.m_USBControllerType = KUSBControllerType_EHCI;
    492         else if (m_pRadioButtonUSB3->isChecked())
     529        else if (   m_pRadioButtonUSB3
     530                 && m_pRadioButtonUSB3->isChecked())
    493531            newUsbData.m_USBControllerType = KUSBControllerType_XHCI;
    494532    }
     
    498536    for (int iFilterIndex = 0; iFilterIndex < pMainRootItem->childCount(); ++iFilterIndex)
    499537    {
    500         /* Gather and cache new filter data: */
     538        /* Gather and cache new data: */
    501539        const UIUSBFilterItem *pItem = static_cast<UIUSBFilterItem*>(pMainRootItem->child(iFilterIndex));
    502540        m_pCache->child(iFilterIndex).cacheCurrentData(*pItem);
     
    10891127bool UIMachineSettingsUSB::saveData()
    10901128{
     1129    /* Sanity check: */
     1130    if (!m_pCache)
     1131        return false;
     1132
    10911133    /* Prepare result: */
    10921134    bool fSuccess = true;
Note: See TracChangeset for help on using the changeset viewer.

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