VirtualBox

Ignore:
Timestamp:
Aug 8, 2017 10:49:57 AM (7 years ago)
Author:
vboxsync
Message:

FE/Qt: Machine settings: Storage page: A complex fix for already a bit complicated storage saving mechanism.

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

Legend:

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

    r66626 r68339  
    39813981        }
    39823982
     3983        /* For each controller ('updating' step): */
     3984        // We need to separately update controllers first because
     3985        // attachments should be removed/updated/created same separate way.
     3986        for (int iControllerIndex = 0; fSuccess && iControllerIndex < m_pCache->childCount(); ++iControllerIndex)
     3987        {
     3988            /* Get controller cache: */
     3989            const UISettingsCacheMachineStorageController &controllerCache = m_pCache->child(iControllerIndex);
     3990
     3991            /* Update controller marked for 'update' (if it can be updated): */
     3992            if (controllerCache.wasUpdated() && isControllerCouldBeUpdated(controllerCache))
     3993                fSuccess = updateStorageController(controllerCache, true);
     3994        }
     3995        for (int iControllerIndex = 0; fSuccess && iControllerIndex < m_pCache->childCount(); ++iControllerIndex)
     3996        {
     3997            /* Get controller cache: */
     3998            const UISettingsCacheMachineStorageController &controllerCache = m_pCache->child(iControllerIndex);
     3999
     4000            /* Update controller marked for 'update' (if it can be updated): */
     4001            if (controllerCache.wasUpdated() && isControllerCouldBeUpdated(controllerCache))
     4002                fSuccess = updateStorageController(controllerCache, false);
     4003        }
     4004
    39834005        /* For each controller ('creating' step): */
     4006        // Finally we are creating new controllers,
     4007        // with attachments which were released for sure.
    39844008        for (int iControllerIndex = 0; fSuccess && iControllerIndex < m_pCache->childCount(); ++iControllerIndex)
    39854009        {
     
    39904014            if (controllerCache.wasCreated() || (controllerCache.wasUpdated() && !isControllerCouldBeUpdated(controllerCache)))
    39914015                fSuccess = createStorageController(controllerCache);
    3992 
    3993             else
    3994 
    3995             /* Update controller marked for 'update' (if it can be updated): */
    3996             if (controllerCache.wasUpdated() && isControllerCouldBeUpdated(controllerCache))
    3997                 fSuccess = updateStorageController(controllerCache);
    39984016        }
    39994017    }
     
    41174135}
    41184136
    4119 bool UIMachineSettingsStorage::updateStorageController(const UISettingsCacheMachineStorageController &controllerCache)
     4137bool UIMachineSettingsStorage::updateStorageController(const UISettingsCacheMachineStorageController &controllerCache,
     4138                                                       bool fRemovingStep)
    41204139{
    41214140    /* Prepare result: */
     
    41794198                notifyOperationProgressError(UIMessageCenter::formatErrorInfo(comController));
    41804199
    4181             /* For each attachment ('removing' step): */
    41824200            // We need to separately remove attachments first because
    4183             // there could be limited amount of attachments available.
    4184             for (int iAttachmentIndex = 0; fSuccess && iAttachmentIndex < controllerCache.childCount(); ++iAttachmentIndex)
     4201            // there could be limited amount of attachments or media available.
     4202            if (fRemovingStep)
    41854203            {
    4186                 /* Get attachment cache: */
    4187                 const UISettingsCacheMachineStorageAttachment &attachmentCache = controllerCache.child(iAttachmentIndex);
    4188 
    4189                 /* Remove attachment marked for 'remove' or 'update' (if it can't be updated): */
    4190                 if (attachmentCache.wasRemoved() || (attachmentCache.wasUpdated() && !isAttachmentCouldBeUpdated(attachmentCache)))
    4191                     fSuccess = removeStorageAttachment(controllerCache, attachmentCache);
     4204                /* For each attachment ('removing' step): */
     4205                for (int iAttachmentIndex = 0; fSuccess && iAttachmentIndex < controllerCache.childCount(); ++iAttachmentIndex)
     4206                {
     4207                    /* Get attachment cache: */
     4208                    const UISettingsCacheMachineStorageAttachment &attachmentCache = controllerCache.child(iAttachmentIndex);
     4209
     4210                    /* Remove attachment marked for 'remove' or 'update' (if it can't be updated): */
     4211                    if (attachmentCache.wasRemoved() || (attachmentCache.wasUpdated() && !isAttachmentCouldBeUpdated(attachmentCache)))
     4212                        fSuccess = removeStorageAttachment(controllerCache, attachmentCache);
     4213                }
    41924214            }
    4193 
    4194             /* For each attachment ('creating' step): */
    4195             for (int iAttachmentIndex = 0; fSuccess && iAttachmentIndex < controllerCache.childCount(); ++iAttachmentIndex)
     4215            else
    41964216            {
    4197                 /* Get attachment cache: */
    4198                 const UISettingsCacheMachineStorageAttachment &attachmentCache = controllerCache.child(iAttachmentIndex);
    4199 
    4200                 /* Create attachment marked for 'create' or 'update' (if it can't be updated): */
    4201                 if (attachmentCache.wasCreated() || (attachmentCache.wasUpdated() && !isAttachmentCouldBeUpdated(attachmentCache)))
    4202                     fSuccess = createStorageAttachment(controllerCache, attachmentCache);
    4203 
    4204                 else
    4205 
    4206                 /* Update attachment marked for 'update' (if it can be updated): */
    4207                 if (attachmentCache.wasUpdated() && isAttachmentCouldBeUpdated(attachmentCache))
    4208                     fSuccess = updateStorageAttachment(controllerCache, attachmentCache);
     4217                /* For each attachment ('creating' step): */
     4218                for (int iAttachmentIndex = 0; fSuccess && iAttachmentIndex < controllerCache.childCount(); ++iAttachmentIndex)
     4219                {
     4220                    /* Get attachment cache: */
     4221                    const UISettingsCacheMachineStorageAttachment &attachmentCache = controllerCache.child(iAttachmentIndex);
     4222
     4223                    /* Create attachment marked for 'create' or 'update' (if it can't be updated): */
     4224                    if (attachmentCache.wasCreated() || (attachmentCache.wasUpdated() && !isAttachmentCouldBeUpdated(attachmentCache)))
     4225                        fSuccess = createStorageAttachment(controllerCache, attachmentCache);
     4226
     4227                    else
     4228
     4229                    /* Update attachment marked for 'update' (if it can be updated): */
     4230                    if (attachmentCache.wasUpdated() && isAttachmentCouldBeUpdated(attachmentCache))
     4231                        fSuccess = updateStorageAttachment(controllerCache, attachmentCache);
     4232                }
    42094233            }
    42104234        }
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsStorage.h

    r66543 r68339  
    775775    bool createStorageController(const UISettingsCacheMachineStorageController &controllerCache);
    776776    /** Updates existing storage controller described by the @a controllerCache. */
    777     bool updateStorageController(const UISettingsCacheMachineStorageController &controllerCache);
     777    bool updateStorageController(const UISettingsCacheMachineStorageController &controllerCache,
     778                                 bool fRemovingStep);
    778779    /** Removes existing storage attachment described by the @a controllerCache and @a attachmentCache. */
    779780    bool removeStorageAttachment(const UISettingsCacheMachineStorageController &controllerCache,
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