VirtualBox

Changeset 38151 in vbox for trunk


Ignore:
Timestamp:
Jul 25, 2011 11:47:29 AM (13 years ago)
Author:
vboxsync
Message:

FE/Qt: Machine settings / Storage page: More strict error-check procedure on settings saving, minor bug-fixes.

File:
1 edited

Legend:

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

    r37956 r38151  
    32043204        {
    32053205            /* For each controller (removing step): */
    3206             for (int iControllerIndex = 0; iControllerIndex < m_cache.childCount(); ++iControllerIndex)
     3206            for (int iControllerIndex = 0; fSuccess && iControllerIndex < m_cache.childCount(); ++iControllerIndex)
    32073207            {
    32083208                /* Get controller cache: */
     
    32123212                if (controllerCache.wasRemoved() || (controllerCache.wasUpdated() && !isControllerCouldBeUpdated(controllerCache)))
    32133213                    fSuccess = removeStorageController(controllerCache);
     3214
     3215                else
    32143216
    32153217                /* Update controllers marked for 'update' (if they can be updated): */
     
    32173219                {
    32183220                    /* For each attachment (removing step): */
    3219                     for (int iAttachmentIndex = 0; iAttachmentIndex < controllerCache.childCount(); ++iAttachmentIndex)
     3221                    for (int iAttachmentIndex = 0; fSuccess && iAttachmentIndex < controllerCache.childCount(); ++iAttachmentIndex)
    32203222                    {
    32213223                        /* Get attachment cache: */
     
    32283230                }
    32293231            }
     3232
    32303233            /* For each controller (creating step): */
    3231             for (int iControllerIndex = 0; iControllerIndex < m_cache.childCount(); ++iControllerIndex)
     3234            for (int iControllerIndex = 0; fSuccess && iControllerIndex < m_cache.childCount(); ++iControllerIndex)
    32323235            {
    32333236                /* Get controller cache: */
    3234                 UICacheSettingsMachineStorageController controllerCache = m_cache.child(iControllerIndex);
     3237                const UICacheSettingsMachineStorageController &controllerCache = m_cache.child(iControllerIndex);
    32353238
    32363239                /* Create controllers marked for 'create' or 'update' (if they can't be updated): */
    32373240                if (controllerCache.wasCreated() || (controllerCache.wasUpdated() && !isControllerCouldBeUpdated(controllerCache)))
    32383241                    fSuccess = createStorageController(controllerCache);
     3242
     3243                else
    32393244
    32403245                /* Update controllers marked for 'update' (if they can be updated): */
     
    32643269        /* Check that machine is OK: */
    32653270        fSuccess = m_machine.isOk();
     3271        /* If controller exists: */
    32663272        if (fSuccess && !controller.isNull())
    32673273        {
     
    32703276            /* For each storage attachment: */
    32713277            for (int iAttachmentIndex = 0; fSuccess && iAttachmentIndex < controllerCache.childCount(); ++iAttachmentIndex)
    3272                 fSuccess = removeStorageAttachment(controllerCache, controllerCache.child(iAttachmentIndex));
     3278            {
     3279                /* Get attachment cache: */
     3280                const UICacheSettingsMachineStorageAttachment &attachmentCache = controllerCache.child(iAttachmentIndex);
     3281
     3282                /* Remove attachment if it was not just 'created': */
     3283                if (!attachmentCache.wasCreated())
     3284                    fSuccess = removeStorageAttachment(controllerCache, attachmentCache);
     3285            }
    32733286            /* Remove storage controller finally: */
    32743287            if (fSuccess)
     
    33053318        fSuccess = !m_machine.isOk();
    33063319        /* If controller doesn't exists: */
    3307         if (controller.isNull())
     3320        if (fSuccess && controller.isNull())
    33083321        {
    33093322            /* Create new storage controller: */
     
    33113324            /* Check that machine is OK: */
    33123325            fSuccess = m_machine.isOk();
    3313             if (!controller.isNull())
     3326            /* If controller exists: */
     3327            if (fSuccess && !controller.isNull())
    33143328            {
    33153329                /* Set storage controller attributes: */
    33163330                controller.SetControllerType(controllerType);
    33173331                controller.SetUseHostIOCache(fUseHostIOCache);
    3318                 if (controllerData.m_controllerBus == KStorageBus_SATA)
     3332                if (controllerBus == KStorageBus_SATA)
    33193333                {
    33203334                    uPortCount = qMax(uPortCount, controller.GetMinPortCount());
     
    33223336                    controller.SetPortCount(uPortCount);
    33233337                }
    3324 
    33253338                /* For each storage attachment: */
    33263339                for (int iAttachmentIndex = 0; fSuccess && iAttachmentIndex < controllerCache.childCount(); ++iAttachmentIndex)
     
    33293342                    const UICacheSettingsMachineStorageAttachment &attachmentCache = controllerCache.child(iAttachmentIndex);
    33303343
    3331                     /* If storage attachment data was not removed: */
     3344                    /* Create attachment if it was not just 'removed': */
    33323345                    if (!attachmentCache.wasRemoved())
    33333346                        fSuccess = createStorageAttachment(controllerCache, attachmentCache);
     
    33603373        /* Check that machine is OK: */
    33613374        fSuccess = m_machine.isOk();
    3362         if (!controller.isNull())
     3375        /* If controller exists: */
     3376        if (fSuccess && !controller.isNull())
    33633377        {
    33643378            /* Set storage controller attributes: */
    33653379            controller.SetControllerType(controllerType);
    33663380            controller.SetUseHostIOCache(fUseHostIOCache);
    3367             if (controllerData.m_controllerBus == KStorageBus_SATA)
     3381            if (controllerBus == KStorageBus_SATA)
    33683382            {
    33693383                uPortCount = qMax(uPortCount, controller.GetMinPortCount());
     
    33713385                controller.SetPortCount(uPortCount);
    33723386            }
    3373 
    33743387            /* For each storage attachment: */
    33753388            for (int iAttachmentIndex = 0; fSuccess && iAttachmentIndex < controllerCache.childCount(); ++iAttachmentIndex)
     
    33823395                    fSuccess = createStorageAttachment(controllerCache, attachmentCache);
    33833396
     3397                else
     3398
    33843399                /* Update attachments marked for 'update' (if they can be updated): */
    33853400                if (attachmentCache.wasUpdated() && isAttachmentCouldBeUpdated(attachmentCache))
     
    34143429        /* Check that machine is OK: */
    34153430        fSuccess = m_machine.isOk();
     3431        /* If attachment exists: */
    34163432        if (fSuccess && !attachment.isNull())
    34173433        {
     
    34583474        /* Check that machine is not OK: */
    34593475        fSuccess = !m_machine.isOk();
    3460         if (attachment.isNull())
     3476        /* If attachment doesn't exists: */
     3477        if (fSuccess && attachment.isNull())
    34613478        {
    34623479            /* Create storage attachment: */
     
    34683485                if (attachmentDeviceType == KDeviceType_DVD)
    34693486                {
    3470                     m_machine.PassthroughDevice(strControllerName, iAttachmentPort, iAttachmentDevice, fAttachmentPassthrough);
    3471                     /* Check that machine is OK: */
    3472                     fSuccess = m_machine.isOk();
     3487                    if (fSuccess)
     3488                    {
     3489                        m_machine.PassthroughDevice(strControllerName, iAttachmentPort, iAttachmentDevice, fAttachmentPassthrough);
     3490                        /* Check that machine is OK: */
     3491                        fSuccess = m_machine.isOk();
     3492                    }
    34733493                    if (fSuccess)
    34743494                    {
     
    35263546        /* Check that machine is OK: */
    35273547        fSuccess = m_machine.isOk();
    3528         if (!attachment.isNull())
     3548        /* If attachment exists: */
     3549        if (fSuccess && !attachment.isNull())
    35293550        {
    35303551            /* Get GUI medium object: */
     
    35383559            if (fSuccess)
    35393560            {
    3540                 if (isMachineOffline())
     3561                if (attachmentDeviceType == KDeviceType_DVD)
    35413562                {
    3542                     if (attachmentDeviceType == KDeviceType_DVD)
     3563                    if (fSuccess && isMachineOffline())
    35433564                    {
    35443565                        m_machine.PassthroughDevice(strControllerName, iAttachmentPort, iAttachmentDevice, fAttachmentPassthrough);
     
    35463567                        fSuccess = m_machine.isOk();
    35473568                    }
    3548                 }
    3549                 if (fSuccess)
    3550                 {
    3551                     if (attachmentDeviceType == KDeviceType_DVD)
     3569                    if (fSuccess && isMachineInValidMode())
    35523570                    {
    35533571                        m_machine.TemporaryEjectDevice(strControllerName, iAttachmentPort, iAttachmentDevice, fAttachmentTempEject);
     
    35563574                    }
    35573575                }
    3558                 if (fSuccess)
     3576                else if (attachmentDeviceType == KDeviceType_HardDisk)
    35593577                {
    3560                     if (attachmentDeviceType == KDeviceType_HardDisk)
     3578                    if (fSuccess && isMachineOffline())
    35613579                    {
    35623580                        m_machine.NonRotationalDevice(strControllerName, iAttachmentPort, iAttachmentDevice, fAttachmentNonRotational);
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