- Timestamp:
- Jul 25, 2011 11:47:29 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsStorage.cpp
r37956 r38151 3204 3204 { 3205 3205 /* 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) 3207 3207 { 3208 3208 /* Get controller cache: */ … … 3212 3212 if (controllerCache.wasRemoved() || (controllerCache.wasUpdated() && !isControllerCouldBeUpdated(controllerCache))) 3213 3213 fSuccess = removeStorageController(controllerCache); 3214 3215 else 3214 3216 3215 3217 /* Update controllers marked for 'update' (if they can be updated): */ … … 3217 3219 { 3218 3220 /* For each attachment (removing step): */ 3219 for (int iAttachmentIndex = 0; iAttachmentIndex < controllerCache.childCount(); ++iAttachmentIndex)3221 for (int iAttachmentIndex = 0; fSuccess && iAttachmentIndex < controllerCache.childCount(); ++iAttachmentIndex) 3220 3222 { 3221 3223 /* Get attachment cache: */ … … 3228 3230 } 3229 3231 } 3232 3230 3233 /* 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) 3232 3235 { 3233 3236 /* Get controller cache: */ 3234 UICacheSettingsMachineStorageControllercontrollerCache = m_cache.child(iControllerIndex);3237 const UICacheSettingsMachineStorageController &controllerCache = m_cache.child(iControllerIndex); 3235 3238 3236 3239 /* Create controllers marked for 'create' or 'update' (if they can't be updated): */ 3237 3240 if (controllerCache.wasCreated() || (controllerCache.wasUpdated() && !isControllerCouldBeUpdated(controllerCache))) 3238 3241 fSuccess = createStorageController(controllerCache); 3242 3243 else 3239 3244 3240 3245 /* Update controllers marked for 'update' (if they can be updated): */ … … 3264 3269 /* Check that machine is OK: */ 3265 3270 fSuccess = m_machine.isOk(); 3271 /* If controller exists: */ 3266 3272 if (fSuccess && !controller.isNull()) 3267 3273 { … … 3270 3276 /* For each storage attachment: */ 3271 3277 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 } 3273 3286 /* Remove storage controller finally: */ 3274 3287 if (fSuccess) … … 3305 3318 fSuccess = !m_machine.isOk(); 3306 3319 /* If controller doesn't exists: */ 3307 if ( controller.isNull())3320 if (fSuccess && controller.isNull()) 3308 3321 { 3309 3322 /* Create new storage controller: */ … … 3311 3324 /* Check that machine is OK: */ 3312 3325 fSuccess = m_machine.isOk(); 3313 if (!controller.isNull()) 3326 /* If controller exists: */ 3327 if (fSuccess && !controller.isNull()) 3314 3328 { 3315 3329 /* Set storage controller attributes: */ 3316 3330 controller.SetControllerType(controllerType); 3317 3331 controller.SetUseHostIOCache(fUseHostIOCache); 3318 if (controller Data.m_controllerBus == KStorageBus_SATA)3332 if (controllerBus == KStorageBus_SATA) 3319 3333 { 3320 3334 uPortCount = qMax(uPortCount, controller.GetMinPortCount()); … … 3322 3336 controller.SetPortCount(uPortCount); 3323 3337 } 3324 3325 3338 /* For each storage attachment: */ 3326 3339 for (int iAttachmentIndex = 0; fSuccess && iAttachmentIndex < controllerCache.childCount(); ++iAttachmentIndex) … … 3329 3342 const UICacheSettingsMachineStorageAttachment &attachmentCache = controllerCache.child(iAttachmentIndex); 3330 3343 3331 /* If storage attachment data was not removed: */3344 /* Create attachment if it was not just 'removed': */ 3332 3345 if (!attachmentCache.wasRemoved()) 3333 3346 fSuccess = createStorageAttachment(controllerCache, attachmentCache); … … 3360 3373 /* Check that machine is OK: */ 3361 3374 fSuccess = m_machine.isOk(); 3362 if (!controller.isNull()) 3375 /* If controller exists: */ 3376 if (fSuccess && !controller.isNull()) 3363 3377 { 3364 3378 /* Set storage controller attributes: */ 3365 3379 controller.SetControllerType(controllerType); 3366 3380 controller.SetUseHostIOCache(fUseHostIOCache); 3367 if (controller Data.m_controllerBus == KStorageBus_SATA)3381 if (controllerBus == KStorageBus_SATA) 3368 3382 { 3369 3383 uPortCount = qMax(uPortCount, controller.GetMinPortCount()); … … 3371 3385 controller.SetPortCount(uPortCount); 3372 3386 } 3373 3374 3387 /* For each storage attachment: */ 3375 3388 for (int iAttachmentIndex = 0; fSuccess && iAttachmentIndex < controllerCache.childCount(); ++iAttachmentIndex) … … 3382 3395 fSuccess = createStorageAttachment(controllerCache, attachmentCache); 3383 3396 3397 else 3398 3384 3399 /* Update attachments marked for 'update' (if they can be updated): */ 3385 3400 if (attachmentCache.wasUpdated() && isAttachmentCouldBeUpdated(attachmentCache)) … … 3414 3429 /* Check that machine is OK: */ 3415 3430 fSuccess = m_machine.isOk(); 3431 /* If attachment exists: */ 3416 3432 if (fSuccess && !attachment.isNull()) 3417 3433 { … … 3458 3474 /* Check that machine is not OK: */ 3459 3475 fSuccess = !m_machine.isOk(); 3460 if (attachment.isNull()) 3476 /* If attachment doesn't exists: */ 3477 if (fSuccess && attachment.isNull()) 3461 3478 { 3462 3479 /* Create storage attachment: */ … … 3468 3485 if (attachmentDeviceType == KDeviceType_DVD) 3469 3486 { 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 } 3473 3493 if (fSuccess) 3474 3494 { … … 3526 3546 /* Check that machine is OK: */ 3527 3547 fSuccess = m_machine.isOk(); 3528 if (!attachment.isNull()) 3548 /* If attachment exists: */ 3549 if (fSuccess && !attachment.isNull()) 3529 3550 { 3530 3551 /* Get GUI medium object: */ … … 3538 3559 if (fSuccess) 3539 3560 { 3540 if ( isMachineOffline())3561 if (attachmentDeviceType == KDeviceType_DVD) 3541 3562 { 3542 if ( attachmentDeviceType == KDeviceType_DVD)3563 if (fSuccess && isMachineOffline()) 3543 3564 { 3544 3565 m_machine.PassthroughDevice(strControllerName, iAttachmentPort, iAttachmentDevice, fAttachmentPassthrough); … … 3546 3567 fSuccess = m_machine.isOk(); 3547 3568 } 3548 } 3549 if (fSuccess) 3550 { 3551 if (attachmentDeviceType == KDeviceType_DVD) 3569 if (fSuccess && isMachineInValidMode()) 3552 3570 { 3553 3571 m_machine.TemporaryEjectDevice(strControllerName, iAttachmentPort, iAttachmentDevice, fAttachmentTempEject); … … 3556 3574 } 3557 3575 } 3558 if (fSuccess)3576 else if (attachmentDeviceType == KDeviceType_HardDisk) 3559 3577 { 3560 if ( attachmentDeviceType == KDeviceType_HardDisk)3578 if (fSuccess && isMachineOffline()) 3561 3579 { 3562 3580 m_machine.NonRotationalDevice(strControllerName, iAttachmentPort, iAttachmentDevice, fAttachmentNonRotational);
Note:
See TracChangeset
for help on using the changeset viewer.