Changeset 90923 in vbox
- Timestamp:
- Aug 26, 2021 4:20:11 PM (3 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter
- Files:
-
- 2 edited
-
UINotificationObjects.cpp (modified) (5 diffs)
-
UINotificationObjects.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.cpp
r90922 r90923 1639 1639 *********************************************************************************************************************************/ 1640 1640 1641 UINotificationProgressSnapshotRestore::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 1641 1650 UINotificationProgressSnapshotRestore::UINotificationProgressSnapshotRestore(const CMachine &comMachine, 1642 const CSnapshot &comSnapshot )1651 const CSnapshot &comSnapshot /* = CSnapshot() */) 1643 1652 : m_comMachine(comMachine) 1644 1653 , m_comSnapshot(comSnapshot) … … 1660 1669 CProgress UINotificationProgressSnapshotRestore::createProgress(COMResult &comResult) 1661 1670 { 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(); 1677 1701 1678 1702 /* Acquire snapshot name: */ … … 1694 1718 /* Open a session thru which we will modify the machine: */ 1695 1719 if (enmSessionState != KSessionState_Unlocked) 1696 m_comSession = uiCommon().openExistingSession( uId);1720 m_comSession = uiCommon().openExistingSession(m_uMachineId); 1697 1721 else 1698 m_comSession = uiCommon().openSession( uId);1722 m_comSession = uiCommon().openSession(m_uMachineId); 1699 1723 if (m_comSession.isNull()) 1700 1724 return CProgress(); … … 1709 1733 } 1710 1734 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 1711 1744 /* Initialize progress-wrapper: */ 1712 1745 CProgress comProgress = comMachine.RestoreSnapshot(m_comSnapshot); 1713 1746 /* Store COM result: */ 1714 comResult = m_comMachine;1747 comResult = comMachine; 1715 1748 /* Return progress-wrapper: */ 1716 1749 return comProgress; … … 1719 1752 void UINotificationProgressSnapshotRestore::sltHandleProgressFinished() 1720 1753 { 1754 /* Unlock session finally: */ 1721 1755 m_comSession.UnlockMachine(); 1722 1756 } -
trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.h
r90922 r90923 1031 1031 1032 1032 /** 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. 1033 1038 * @param comMachine Brings the machine we are restoring snapshot for. 1034 1039 * @param comSnapshot Brings the snapshot being restored. */ 1035 1040 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 1043 protected: 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 1052 private slots: 1053 1054 /** Handles signal about progress being finished. */ 1055 void sltHandleProgressFinished(); 1056 1057 private: 1058 1059 /** Holds the ID of machine we are restoring snapshot for. */ 1060 QUuid m_uMachineId; 1054 1061 /** Holds the machine we are restoring snapshot for. */ 1055 1062 CMachine m_comMachine;
Note:
See TracChangeset
for help on using the changeset viewer.

