VirtualBox

Changeset 90923 in vbox


Ignore:
Timestamp:
Aug 26, 2021 4:20:11 PM (3 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10067: Reworking r146061; UINotificationProgressSnapshotRestore should now be usable from within Runtime UI as well; Snapshot can now be NULL which means current one will be used.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.cpp

    r90922 r90923  
    16391639*********************************************************************************************************************************/
    16401640
     1641UINotificationProgressSnapshotRestore::UINotificationProgressSnapshotRestore(const QUuid &uMachineId,
     1642                                                                             const CSnapshot &comSnapshot /* = CSnapshot() */)
     1643    : m_uMachineId(uMachineId)
     1644    , m_comSnapshot(comSnapshot)
     1645{
     1646    connect(this, &UINotificationProgress::sigProgressFinished,
     1647            this, &UINotificationProgressSnapshotRestore::sltHandleProgressFinished);
     1648}
     1649
    16411650UINotificationProgressSnapshotRestore::UINotificationProgressSnapshotRestore(const CMachine &comMachine,
    1642                                                                              const CSnapshot &comSnapshot)
     1651                                                                             const CSnapshot &comSnapshot /* = CSnapshot() */)
    16431652    : m_comMachine(comMachine)
    16441653    , m_comSnapshot(comSnapshot)
     
    16601669CProgress UINotificationProgressSnapshotRestore::createProgress(COMResult &comResult)
    16611670{
    1662     /* Acquire VM id: */
    1663     const QUuid uId = m_comMachine.GetId();
    1664     if (!m_comMachine.isOk())
    1665     {
    1666         comResult = m_comMachine;
    1667         return CProgress();
    1668     }
    1669 
    1670     /* Acquire VM name: */
    1671     m_strMachineName = m_comMachine.GetName();
    1672     if (!m_comMachine.isOk())
    1673     {
    1674         comResult = m_comMachine;
    1675         return CProgress();
    1676     }
     1671    /* Make sure machine ID defined: */
     1672    if (m_uMachineId.isNull())
     1673    {
     1674        /* Acquire VM id: */
     1675        AssertReturn(m_comMachine.isNotNull(), CProgress());
     1676        m_uMachineId = m_comMachine.GetId();
     1677        if (!m_comMachine.isOk())
     1678        {
     1679            comResult = m_comMachine;
     1680            return CProgress();
     1681        }
     1682    }
     1683
     1684    /* Make sure machine defined: */
     1685    if (m_comMachine.isNull())
     1686    {
     1687        /* Acquire VM: */
     1688        AssertReturn(!m_uMachineId.isNull(), CProgress());
     1689        CVirtualBox comVBox = uiCommon().virtualBox();
     1690        m_comMachine = comVBox.FindMachine(m_uMachineId.toString());
     1691        if (!comVBox.isOk())
     1692        {
     1693            comResult = comVBox;
     1694            return CProgress();
     1695        }
     1696    }
     1697
     1698    /* Make sure snapshot is defined: */
     1699    if (m_comSnapshot.isNull())
     1700        m_comSnapshot = m_comMachine.GetCurrentSnapshot();
    16771701
    16781702    /* Acquire snapshot name: */
     
    16941718    /* Open a session thru which we will modify the machine: */
    16951719    if (enmSessionState != KSessionState_Unlocked)
    1696         m_comSession = uiCommon().openExistingSession(uId);
     1720        m_comSession = uiCommon().openExistingSession(m_uMachineId);
    16971721    else
    1698         m_comSession = uiCommon().openSession(uId);
     1722        m_comSession = uiCommon().openSession(m_uMachineId);
    16991723    if (m_comSession.isNull())
    17001724        return CProgress();
     
    17091733    }
    17101734
     1735    /* Acquire VM name: */
     1736    m_strMachineName = comMachine.GetName();
     1737    if (!comMachine.isOk())
     1738    {
     1739        comResult = comMachine;
     1740        m_comSession.UnlockMachine();
     1741        return CProgress();
     1742    }
     1743
    17111744    /* Initialize progress-wrapper: */
    17121745    CProgress comProgress = comMachine.RestoreSnapshot(m_comSnapshot);
    17131746    /* Store COM result: */
    1714     comResult = m_comMachine;
     1747    comResult = comMachine;
    17151748    /* Return progress-wrapper: */
    17161749    return comProgress;
     
    17191752void UINotificationProgressSnapshotRestore::sltHandleProgressFinished()
    17201753{
     1754    /* Unlock session finally: */
    17211755    m_comSession.UnlockMachine();
    17221756}
  • trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.h

    r90922 r90923  
    10311031
    10321032    /** Constructs snapshot restore notification-progress.
     1033      * @param  uMachineId   Brings the ID of machine we are restoring snapshot for.
     1034      * @param  comSnapshot  Brings the snapshot being restored. */
     1035    UINotificationProgressSnapshotRestore(const QUuid &uMachineId,
     1036                                          const CSnapshot &comSnapshot = CSnapshot());
     1037    /** Constructs snapshot restore notification-progress.
    10331038      * @param  comMachine   Brings the machine we are restoring snapshot for.
    10341039      * @param  comSnapshot  Brings the snapshot being restored. */
    10351040    UINotificationProgressSnapshotRestore(const CMachine &comMachine,
    1036                                           const CSnapshot &comSnapshot);
    1037 
    1038 protected:
    1039 
    1040     /** Returns object name. */
    1041     virtual QString name() const /* override final */;
    1042     /** Returns object details. */
    1043     virtual QString details() const /* override final */;
    1044     /** Creates and returns started progress-wrapper. */
    1045     virtual CProgress createProgress(COMResult &comResult) /* override final */;
    1046 
    1047 private slots:
    1048 
    1049     /** Handles signal about progress being finished. */
    1050     void sltHandleProgressFinished();
    1051 
    1052 private:
    1053 
     1041                                          const CSnapshot &comSnapshot = CSnapshot());
     1042
     1043protected:
     1044
     1045    /** Returns object name. */
     1046    virtual QString name() const /* override final */;
     1047    /** Returns object details. */
     1048    virtual QString details() const /* override final */;
     1049    /** Creates and returns started progress-wrapper. */
     1050    virtual CProgress createProgress(COMResult &comResult) /* override final */;
     1051
     1052private slots:
     1053
     1054    /** Handles signal about progress being finished. */
     1055    void sltHandleProgressFinished();
     1056
     1057private:
     1058
     1059    /** Holds the ID of machine we are restoring snapshot for. */
     1060    QUuid      m_uMachineId;
    10541061    /** Holds the machine we are restoring snapshot for. */
    10551062    CMachine   m_comMachine;
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