VirtualBox

Changeset 92014 in vbox for trunk/src


Ignore:
Timestamp:
Oct 22, 2021 6:16:38 PM (3 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10067: UIWizardCloneVM: Migrate intermediate progress related to snapshot creating to notification-center.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVM.cpp

    r91094 r92014  
    141141    CMachine srcMachine = m_machine;
    142142
    143     /* If the user like to create a linked clone from the current machine, we
    144      * have to take a little bit more action. First we create an snapshot, so
    145      * that new differencing images on the source VM are created. Based on that
    146      * we could use the new snapshot machine for cloning. */
     143    /* If the user like to create a linked clone from the current machine, we have to take a little bit more action.
     144     * First we create an snapshot, so that new differencing images on the source VM are created. Based on that we
     145     * could use the new snapshot machine for cloning. */
    147146    if (m_fLinkedClone && m_snapshot.isNull())
    148147    {
    149         /* Acquire machine name beforehand: */
    150         const QString strMachineName = m_machine.GetName();
    151 
    152         /* Open session: */
    153         CSession comSession = uiCommon().openSession(m_machine.GetId());
    154         if (comSession.isNull())
     148        /* Compose snapshot name: */
     149        const QString strSnapshotName = tr("Linked Base for %1 and %2").arg(m_machine.GetName()).arg(m_strCloneName);
     150
     151        /* Take the snapshot: */
     152        UINotificationProgressSnapshotTake *pNotification = new UINotificationProgressSnapshotTake(srcMachine,
     153                                                                                                   strSnapshotName,
     154                                                                                                   QString());
     155        UINotificationReceiver receiver;
     156        connect(pNotification, &UINotificationProgressSnapshotTake::sigSnapshotTaken,
     157                &receiver, &UINotificationReceiver::setReceiverProperty);
     158        if (!handleNotificationProgressNow(pNotification))
    155159            return false;
    156160
    157         /* Acquire session machine: */
    158         CMachine comSessionMachine = comSession.GetMachine();
    159 
    160         /* Take the snapshot: */
    161         const QString strSnapshotName = tr("Linked Base for %1 and %2").arg(strMachineName).arg(m_strCloneName);
    162         QUuid uSnapshotId;
    163         CProgress comProgress = comSessionMachine.TakeSnapshot(strSnapshotName, "", true, uSnapshotId);
    164         if (!comSessionMachine.isOk())
    165         {
    166             msgCenter().cannotTakeSnapshot(comSessionMachine, strMachineName, this);
     161        /* Acquire created snapshot id: */
     162        QUuid uSnapshotId = receiver.property("received_value").toUuid();
     163
     164        /* Look for created snapshot: */
     165        const CSnapshot comCreatedSnapshot = m_machine.FindSnapshot(uSnapshotId.toString());
     166        if (comCreatedSnapshot.isNull())
     167        {
     168            msgCenter().cannotFindSnapshotByName(m_machine, strSnapshotName, this);
    167169            return false;
    168170        }
    169         else
    170         {
    171             /* Make sure progress initially valid: */
    172             if (!comProgress.isNull() && !comProgress.GetCompleted())
    173             {
    174                 /* Create take snapshot progress object: */
    175                 QPointer<UIProgressObject> pObject = new UIProgressObject(comProgress, this);
    176                 if (pObject)
    177                 {
    178                     connect(pObject.data(), &UIProgressObject::sigProgressChange,
    179                             this, &UIWizardCloneVM::sltHandleProgressChange);
    180                     connect(pObject.data(), &UIProgressObject::sigProgressComplete,
    181                             this, &UIWizardCloneVM::sltHandleProgressFinished);
    182                     sltHandleProgressStarted();
    183                     pObject->exec();
    184                     if (pObject)
    185                         delete pObject;
    186                     else
    187                     {
    188                         // Premature application shutdown,
    189                         // exit immediately:
    190                         return false;
    191                     }
    192                 }
    193             }
    194 
    195             /* Check progress for errors: */
    196             if (!comProgress.isOk() || comProgress.GetResultCode() != 0)
    197             {
    198                 msgCenter().cannotTakeSnapshot(comProgress, strMachineName, this);
    199                 return false;
    200             }
    201             else
    202             {
    203                 /* Look for created snapshot: */
    204                 const CSnapshot comCreatedSnapshot = m_machine.FindSnapshot(uSnapshotId.toString());
    205                 if (comCreatedSnapshot.isNull())
    206                 {
    207                     msgCenter().cannotFindSnapshotByName(m_machine, strSnapshotName, this);
    208                     return false;
    209                 }
    210 
    211                 /* Update machine for cloning finally: */
    212                 srcMachine = comCreatedSnapshot.GetMachine();
    213             }
    214         }
    215 
    216         /* Unlock machine finally: */
    217         comSession.UnlockMachine();
     171
     172        /* Update machine for cloning finally: */
     173        srcMachine = comCreatedSnapshot.GetMachine();
    218174    }
    219175
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