Changeset 64604 in vbox for trunk/src/VBox
- Timestamp:
- Nov 8, 2016 6:14:23 PM (8 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIDefs.h
r62493 r64604 137 137 Q_DECLARE_METATYPE(StorageSlot); 138 138 139 /** Common UI: Storage-slot struct extension with exact controller name. */ 140 struct ExactStorageSlot : public StorageSlot 141 { 142 ExactStorageSlot(const QString &strController, 143 KStorageBus enmBus, LONG iPort, LONG iDevice) 144 : StorageSlot(enmBus, iPort, iDevice) 145 , controller(strController) 146 {} 147 QString controller; 148 }; 149 139 150 #endif /* !___UIDefs_h___ */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp
r64102 r64604 592 592 AssertReturnVoid(!strMediumID.isNull()); 593 593 594 /* Search ing for the first suitable controller/slot: */595 Q String strControllerName;596 LONG iCntPort = -1, iCntDevice = -1;594 /* Search for a suitable storage slots: */ 595 QList<ExactStorageSlot> freeStorageSlots; 596 QList<ExactStorageSlot> busyStorageSlots; 597 597 foreach (const CStorageController &controller, machine().GetStorageControllers()) 598 598 { 599 599 foreach (const CMediumAttachment &attachment, machine().GetMediumAttachmentsOfController(controller.GetName())) 600 600 { 601 /* Look for an optical device: */ 601 602 if (attachment.GetType() == KDeviceType_DVD) 602 603 { 603 strControllerName = controller.GetName(); 604 iCntPort = attachment.GetPort(); 605 iCntDevice = attachment.GetDevice(); 606 break; 604 /* Append storage slot to corresponding list: */ 605 if (attachment.GetMedium().isNull()) 606 freeStorageSlots << ExactStorageSlot(controller.GetName(), controller.GetBus(), 607 attachment.GetPort(), attachment.GetDevice()); 608 else 609 busyStorageSlots << ExactStorageSlot(controller.GetName(), controller.GetBus(), 610 attachment.GetPort(), attachment.GetDevice()); 607 611 } 608 612 } 609 if (!strControllerName.isNull()) 610 break; 611 } 612 613 /* Make sure suitable controller/slot were found: */ 614 if (strControllerName.isNull()) 613 } 614 615 /* Make sure at least one storage slot found: */ 616 QList<ExactStorageSlot> storageSlots = freeStorageSlots + busyStorageSlots; 617 if (storageSlots.isEmpty()) 615 618 { 616 619 msgCenter().cannotMountGuestAdditions(machineName()); … … 627 630 } 628 631 629 /* Mount medium to corresponding controller/slot: */ 630 machine().MountMedium(strControllerName, iCntPort, iCntDevice, medium.medium(), false /* force */); 632 /* Try to mount medium to first storage slot: */ 633 bool fMounted = false; 634 while (!storageSlots.isEmpty() && !fMounted) 635 { 636 const ExactStorageSlot storageSlot = storageSlots.takeFirst(); 637 machine().MountMedium(storageSlot.controller, storageSlot.port, storageSlot.device, medium.medium(), false /* force */); 638 if (machine().isOk()) 639 fMounted = true; 640 } 631 641 if (!machine().isOk()) 632 642 { 633 /* Ask for force mounting: */ 634 if (msgCenter().cannotRemountMedium(machine(), medium, true /* mount? */, 635 true /* retry? */, mainMachineWindow())) 636 { 637 /* Force mount medium to the predefined port/device: */ 638 machine().MountMedium(strControllerName, iCntPort, iCntDevice, medium.medium(), true /* force */); 639 if (!machine().isOk()) 640 msgCenter().cannotRemountMedium(machine(), medium, true /* mount? */, 641 false /* retry? */, mainMachineWindow()); 642 } 643 msgCenter().cannotRemountMedium(machine(), medium, true /* mount? */, 644 false /* retry? */, mainMachineWindow()); 643 645 } 644 646 }
Note:
See TracChangeset
for help on using the changeset viewer.