VirtualBox

Changeset 94666 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Apr 21, 2022 11:30:04 AM (3 years ago)
Author:
vboxsync
Message:

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

Location:
trunk/src/VBox/Frontends/VirtualBox/src/settings/global
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsDisplay.cpp

    r94357 r94666  
    8484void UIGlobalSettingsDisplay::loadToCacheFrom(QVariant &data)
    8585{
     86    /* Sanity check: */
     87    if (!m_pCache)
     88        return;
     89
    8690    /* Fetch data to properties: */
    8791    UISettingsPageGlobal::fetchData(data);
     
    107111void UIGlobalSettingsDisplay::getFromCache()
    108112{
     113    /* Sanity check: */
     114    if (!m_pCache)
     115        return;
     116
    109117    /* Load old data from cache: */
    110118    const UIDataSettingsGlobalDisplay &oldData = m_pCache->base();
    111     m_pEditorMaximumGuestScreenSize->setValue(oldData.m_guiMaximumGuestScreenSizeValue);
    112     m_pEditorScaleFactor->setScaleFactors(oldData.m_scaleFactors);
    113     m_pEditorScaleFactor->setMonitorCount(gpDesktop->screenCount());
    114     m_pEditorGlobalDisplayFeatures->setActivateOnMouseHover(oldData.m_fActivateHoveredMachineWindow);
    115     m_pEditorGlobalDisplayFeatures->setDisableHostScreenSaver(oldData.m_fDisableHostScreenSaver);
     119    if (m_pEditorMaximumGuestScreenSize)
     120        m_pEditorMaximumGuestScreenSize->setValue(oldData.m_guiMaximumGuestScreenSizeValue);
     121    if (m_pEditorScaleFactor)
     122    {
     123        m_pEditorScaleFactor->setScaleFactors(oldData.m_scaleFactors);
     124        m_pEditorScaleFactor->setMonitorCount(gpDesktop->screenCount());
     125    }
     126    if (m_pEditorGlobalDisplayFeatures)
     127    {
     128        m_pEditorGlobalDisplayFeatures->setActivateOnMouseHover(oldData.m_fActivateHoveredMachineWindow);
     129        m_pEditorGlobalDisplayFeatures->setDisableHostScreenSaver(oldData.m_fDisableHostScreenSaver);
     130    }
    116131}
    117132
    118133void UIGlobalSettingsDisplay::putToCache()
    119134{
     135    /* Sanity check: */
     136    if (!m_pCache)
     137        return;
     138
    120139    /* Prepare new data: */
    121140    UIDataSettingsGlobalDisplay newData = m_pCache->base();
    122141
    123142    /* Cache new data: */
    124     newData.m_guiMaximumGuestScreenSizeValue = m_pEditorMaximumGuestScreenSize->value();
    125     newData.m_scaleFactors = m_pEditorScaleFactor->scaleFactors();
    126     newData.m_fActivateHoveredMachineWindow = m_pEditorGlobalDisplayFeatures->activateOnMouseHover();
    127     newData.m_fDisableHostScreenSaver = m_pEditorGlobalDisplayFeatures->disableHostScreenSaver();
     143    if (m_pEditorMaximumGuestScreenSize)
     144        newData.m_guiMaximumGuestScreenSizeValue = m_pEditorMaximumGuestScreenSize->value();
     145    if (m_pEditorScaleFactor)
     146        newData.m_scaleFactors = m_pEditorScaleFactor->scaleFactors();
     147    if (m_pEditorGlobalDisplayFeatures)
     148    {
     149        newData.m_fActivateHoveredMachineWindow = m_pEditorGlobalDisplayFeatures->activateOnMouseHover();
     150        newData.m_fDisableHostScreenSaver = m_pEditorGlobalDisplayFeatures->disableHostScreenSaver();
     151    }
    128152    m_pCache->cacheCurrentData(newData);
    129153}
     
    201225bool UIGlobalSettingsDisplay::saveData()
    202226{
     227    /* Sanity check: */
     228    if (!m_pCache)
     229        return false;
     230
    203231    /* Prepare result: */
    204232    bool fSuccess = true;
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsGeneral.cpp

    r94288 r94666  
    7676void UIGlobalSettingsGeneral::loadToCacheFrom(QVariant &data)
    7777{
     78    /* Sanity check: */
     79    if (!m_pCache)
     80        return;
     81
    7882    /* Fetch data to properties: */
    7983    UISettingsPageGlobal::fetchData(data);
     
    9498void UIGlobalSettingsGeneral::getFromCache()
    9599{
     100    /* Sanity check: */
     101    if (!m_pCache)
     102        return;
     103
    96104    /* Load old data from cache: */
    97105    const UIDataSettingsGlobalGeneral &oldData = m_pCache->base();
    98     m_pEditorDefaultMachineFolder->setValue(oldData.m_strDefaultMachineFolder);
    99     m_pEditorVRDEAuthLibrary->setValue(oldData.m_strVRDEAuthLibrary);
     106    if (m_pEditorDefaultMachineFolder)
     107        m_pEditorDefaultMachineFolder->setValue(oldData.m_strDefaultMachineFolder);
     108    if (m_pEditorVRDEAuthLibrary)
     109        m_pEditorVRDEAuthLibrary->setValue(oldData.m_strVRDEAuthLibrary);
    100110}
    101111
    102112void UIGlobalSettingsGeneral::putToCache()
    103113{
     114    /* Sanity check: */
     115    if (!m_pCache)
     116        return;
     117
    104118    /* Prepare new data: */
    105119    UIDataSettingsGlobalGeneral newData = m_pCache->base();
    106120
    107121    /* Cache new data: */
    108     newData.m_strDefaultMachineFolder = m_pEditorDefaultMachineFolder->value();
    109     newData.m_strVRDEAuthLibrary = m_pEditorVRDEAuthLibrary->value();
     122    if (m_pEditorDefaultMachineFolder)
     123        newData.m_strDefaultMachineFolder = m_pEditorDefaultMachineFolder->value();
     124    if (m_pEditorVRDEAuthLibrary)
     125        newData.m_strVRDEAuthLibrary = m_pEditorVRDEAuthLibrary->value();
    110126    m_pCache->cacheCurrentData(newData);
    111127}
     
    176192bool UIGlobalSettingsGeneral::saveData()
    177193{
     194    /* Sanity check: */
     195    if (!m_pCache)
     196        return false;
     197
    178198    /* Prepare result: */
    179199    bool fSuccess = true;
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsInput.cpp

    r94323 r94666  
    7777void UIGlobalSettingsInput::loadToCacheFrom(QVariant &data)
    7878{
     79    /* Sanity check: */
     80    if (!m_pCache)
     81        return;
     82
    7983    /* Fetch data to properties: */
    8084    UISettingsPageGlobal::fetchData(data);
     
    112116void UIGlobalSettingsInput::getFromCache()
    113117{
     118    /* Sanity check: */
     119    if (!m_pCache)
     120        return;
     121
    114122    /* Load old data from cache: */
    115123    const UIDataSettingsGlobalInput &oldData = m_pCache->base();
    116     m_pEditorShortcutConfiguration->load(oldData.m_shortcuts);
    117     m_pEditorAutoCaptureKeyboard->setValue(oldData.m_fAutoCapture);
     124    if (m_pEditorShortcutConfiguration)
     125        m_pEditorShortcutConfiguration->load(oldData.m_shortcuts);
     126    if (m_pEditorAutoCaptureKeyboard)
     127        m_pEditorAutoCaptureKeyboard->setValue(oldData.m_fAutoCapture);
    118128
    119129    /* Revalidate: */
     
    123133void UIGlobalSettingsInput::putToCache()
    124134{
     135    /* Sanity check: */
     136    if (!m_pCache)
     137        return;
     138
    125139    /* Prepare new data: */
    126140    UIDataSettingsGlobalInput newData = m_pCache->base();
    127141
    128142    /* Cache new data: */
    129     m_pEditorShortcutConfiguration->save(newData.m_shortcuts);
    130     newData.m_fAutoCapture = m_pEditorAutoCaptureKeyboard->value();
     143    if (m_pEditorShortcutConfiguration)
     144        m_pEditorShortcutConfiguration->save(newData.m_shortcuts);
     145    if (m_pEditorAutoCaptureKeyboard)
     146        newData.m_fAutoCapture = m_pEditorAutoCaptureKeyboard->value();
    131147    m_pCache->cacheCurrentData(newData);
    132148}
     
    224240bool UIGlobalSettingsInput::saveData()
    225241{
     242    /* Sanity check: */
     243    if (!m_pCache)
     244        return false;
     245
    226246    /* Prepare result: */
    227247    bool fSuccess = true;
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsInterface.cpp

    r94333 r94666  
    6969void UIGlobalSettingsInterface::loadToCacheFrom(QVariant &data)
    7070{
     71    /* Sanity check: */
     72    if (!m_pCache)
     73        return;
     74
    7175    /* Fetch data to properties: */
    7276    UISettingsPageGlobal::fetchData(data);
     
    8690void UIGlobalSettingsInterface::getFromCache()
    8791{
     92    /* Sanity check: */
     93    if (!m_pCache)
     94        return;
     95
    8896    /* Load old data from cache: */
    8997    const UIDataSettingsGlobalInterface &oldData = m_pCache->base();
    90     m_pEditorColorTheme->setValue(oldData.m_enmColorTheme);
     98    if (m_pEditorColorTheme)
     99        m_pEditorColorTheme->setValue(oldData.m_enmColorTheme);
    91100
    92101    /* Revalidate: */
     
    96105void UIGlobalSettingsInterface::putToCache()
    97106{
     107    /* Sanity check: */
     108    if (!m_pCache)
     109        return;
     110
    98111    /* Prepare new data: */
    99112    UIDataSettingsGlobalInterface newData;
    100113
    101114    /* Cache new data: */
    102     newData.m_enmColorTheme = m_pEditorColorTheme->value();
     115    if (m_pEditorColorTheme)
     116        newData.m_enmColorTheme = m_pEditorColorTheme->value();
    103117    m_pCache->cacheCurrentData(newData);
    104118}
     
    158172bool UIGlobalSettingsInterface::saveData()
    159173{
     174    /* Sanity check: */
     175    if (!m_pCache)
     176        return false;
     177
    160178    /* Prepare result: */
    161179    bool fSuccess = true;
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsLanguage.cpp

    r94323 r94666  
    6969void UIGlobalSettingsLanguage::loadToCacheFrom(QVariant &data)
    7070{
     71    /* Sanity check: */
     72    if (!m_pCache)
     73        return;
     74
    7175    /* Fetch data to properties: */
    7276    UISettingsPageGlobal::fetchData(data);
     
    8690void UIGlobalSettingsLanguage::getFromCache()
    8791{
     92    /* Sanity check: */
     93    if (!m_pCache)
     94        return;
     95
    8896    /* Load old data from cache: */
    8997    const UIDataSettingsGlobalLanguage &oldData = m_pCache->base();
    90     m_pEditorLanguageSettings->setValue(oldData.m_strLanguageId);
     98    if (m_pEditorLanguageSettings)
     99        m_pEditorLanguageSettings->setValue(oldData.m_strLanguageId);
    91100}
    92101
    93102void UIGlobalSettingsLanguage::putToCache()
    94103{
     104    /* Sanity check: */
     105    if (!m_pCache)
     106        return;
     107
    95108    /* Prepare new data: */
    96109    UIDataSettingsGlobalLanguage newData = m_pCache->base();
    97110
    98111    /* Cache new data: */
    99     newData.m_strLanguageId = m_pEditorLanguageSettings->value();
     112    if (m_pEditorLanguageSettings)
     113        newData.m_strLanguageId = m_pEditorLanguageSettings->value();
    100114    m_pCache->cacheCurrentData(newData);
    101115}
     
    152166bool UIGlobalSettingsLanguage::saveData()
    153167{
     168    /* Sanity check: */
     169    if (!m_pCache)
     170        return false;
     171
    154172    /* Prepare result: */
    155173    bool fSuccess = true;
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsProxy.cpp

    r94323 r94666  
    7676void UIGlobalSettingsProxy::loadToCacheFrom(QVariant &data)
    7777{
     78    /* Sanity check: */
     79    if (!m_pCache)
     80        return;
     81
    7882    /* Fetch data to properties: */
    7983    UISettingsPageGlobal::fetchData(data);
     
    9498void UIGlobalSettingsProxy::getFromCache()
    9599{
     100    /* Sanity check: */
     101    if (!m_pCache)
     102        return;
     103
    96104    /* Load old data from cache: */
    97105    const UIDataSettingsGlobalProxy &oldData = m_pCache->base();
    98     m_pEditorGlobalProxyFeatures->setProxyMode(oldData.m_enmProxyMode);
    99     m_pEditorGlobalProxyFeatures->setProxyHost(oldData.m_strProxyHost);
     106    if (m_pEditorGlobalProxyFeatures)
     107    {
     108        m_pEditorGlobalProxyFeatures->setProxyMode(oldData.m_enmProxyMode);
     109        m_pEditorGlobalProxyFeatures->setProxyHost(oldData.m_strProxyHost);
     110    }
    100111
    101112    /* Revalidate: */
     
    105116void UIGlobalSettingsProxy::putToCache()
    106117{
     118    /* Sanity check: */
     119    if (!m_pCache)
     120        return;
     121
    107122    /* Prepare new data: */
    108123    UIDataSettingsGlobalProxy newData = m_pCache->base();
    109124
    110125    /* Cache new data: */
    111     newData.m_enmProxyMode = m_pEditorGlobalProxyFeatures->proxyMode();
    112     newData.m_strProxyHost = m_pEditorGlobalProxyFeatures->proxyHost();
     126    if (m_pEditorGlobalProxyFeatures)
     127    {
     128        newData.m_enmProxyMode = m_pEditorGlobalProxyFeatures->proxyMode();
     129        newData.m_strProxyHost = m_pEditorGlobalProxyFeatures->proxyHost();
     130    }
    113131    m_pCache->cacheCurrentData(newData);
    114132}
     
    225243bool UIGlobalSettingsProxy::saveData()
    226244{
     245    /* Sanity check: */
     246    if (!m_pCache)
     247        return false;
     248
    227249    /* Prepare result: */
    228250    bool fSuccess = true;
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsUpdate.cpp

    r94323 r94666  
    6969void UIGlobalSettingsUpdate::loadToCacheFrom(QVariant &data)
    7070{
     71    /* Sanity check: */
     72    if (!m_pCache)
     73        return;
     74
    7175    /* Fetch data to properties: */
    7276    UISettingsPageGlobal::fetchData(data);
     
    8690void UIGlobalSettingsUpdate::getFromCache()
    8791{
     92    /* Sanity check: */
     93    if (!m_pCache)
     94        return;
     95
    8896    /* Load old data from cache: */
    8997    const UIDataSettingsGlobalUpdate &oldData = m_pCache->base();
    90     m_pEditorUpdateSettings->setValue(oldData.m_guiUpdateData);
     98    if (m_pEditorUpdateSettings)
     99        m_pEditorUpdateSettings->setValue(oldData.m_guiUpdateData);
    91100}
    92101
    93102void UIGlobalSettingsUpdate::putToCache()
    94103{
     104    /* Sanity check: */
     105    if (!m_pCache)
     106        return;
     107
    95108    /* Prepare new data: */
    96109    UIDataSettingsGlobalUpdate newData = m_pCache->base();
    97110
    98111    /* Cache new data: */
    99     newData.m_guiUpdateData = m_pEditorUpdateSettings->value();
     112    if (m_pEditorUpdateSettings)
     113        newData.m_guiUpdateData = m_pEditorUpdateSettings->value();
    100114    m_pCache->cacheCurrentData(newData);
    101115}
     
    155169bool UIGlobalSettingsUpdate::saveData()
    156170{
     171    /* Sanity check: */
     172    if (!m_pCache)
     173        return false;
     174
    157175    /* Prepare result: */
    158176    bool fSuccess = true;
Note: See TracChangeset for help on using the changeset viewer.

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