- Timestamp:
- Sep 12, 2017 11:06:05 AM (7 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.cpp
r68679 r68721 946 946 .arg(strSnapshotName).arg(strMachineName), 947 947 UIErrorString::formatErrorInfo(progress)); 948 } 949 950 void UIMessageCenter::cannotChangeSnapshot(const CSnapshot &comSnapshot, const QString &strSnapshotName, const QString &strMachineName) const 951 { 952 error(0, MessageType_Error, 953 tr("Failed to change the snapshot <b>%1</b> of the virtual machine <b>%2</b>.") 954 .arg(strSnapshotName).arg(strMachineName), 955 UIErrorString::formatErrorInfo(comSnapshot)); 948 956 } 949 957 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.h
r68679 r68721 212 212 void cannotRemoveSnapshot(const CMachine &machine, const QString &strSnapshotName, const QString &strMachineName) const; 213 213 void cannotRemoveSnapshot(const CProgress &progress, const QString &strSnapshotName, const QString &strMachineName) const; 214 void cannotChangeSnapshot(const CSnapshot &comSnapshot, const QString &strSnapshotName, const QString &strMachineName) const; 214 215 void cannotFindSnapshotByName(const CMachine &comMachine, const QString &strName, QWidget *pParent = 0) const; 215 216 void cannotFindSnapshotById(const CMachine &comMachine, const QString &strId, QWidget *pParent = 0) const; -
trunk/src/VBox/Frontends/VirtualBox/src/selector/UISnapshotPane.cpp
r68418 r68721 926 926 void UISnapshotPane::sltApplySnapshotDetailsChanges() 927 927 { 928 /* Make sure nothing being edited in the meantime: */ 929 if (!m_pLockReadWrite->tryLockForWrite()) 930 return; 931 932 /* Acquire "current snapshot" item: */ 928 /* Acquire selected item: */ 933 929 const UISnapshotItem *pSnapshotItem = UISnapshotItem::toSnapshotItem(m_pSnapshotTree->currentItem()); 934 AssertPtr(pSnapshotItem); 935 if (pSnapshotItem) 936 { 930 AssertPtrReturnVoid(pSnapshotItem); 931 932 /* For snapshot items: */ 933 if (!pSnapshotItem->isCurrentStateItem()) 934 { 935 /* Make sure nothing being edited in the meantime: */ 936 if (!m_pLockReadWrite->tryLockForWrite()) 937 return; 938 937 939 /* Make sure that's a snapshot item indeed: */ 938 940 CSnapshot comSnapshot = pSnapshotItem->snapshot(); 939 if (comSnapshot.isNotNull()) 941 AssertReturnVoid(comSnapshot.isNotNull()); 942 943 /* Get item data: */ 944 UIDataSnapshot oldData = *pSnapshotItem; 945 UIDataSnapshot newData = m_pDetailsWidget->data(); 946 AssertReturnVoid(newData != oldData); 947 948 /* Open a session (this call will handle all errors): */ 949 CSession comSession; 950 if (m_enmSessionState != KSessionState_Unlocked) 951 comSession = vboxGlobal().openExistingSession(m_strMachineId); 952 else 953 comSession = vboxGlobal().openSession(m_strMachineId); 954 if (comSession.isNotNull()) 940 955 { 941 /* Get item data: */ 942 UIDataSnapshot oldData = *pSnapshotItem; 943 UIDataSnapshot newData = m_pDetailsWidget->data(); 944 945 /* Update corresponding snapshot attributes if necessary: */ 946 if (newData != oldData) 956 /* Get corresponding machine object: */ 957 CMachine comMachine = comSession.GetMachine(); 958 959 /* Perform separate independent steps: */ 960 do 947 961 { 948 /* We need to open a session when we manipulate the snapshot data of a machine: */ 949 CSession comSession = vboxGlobal().openExistingSession(comSnapshot.GetMachine().GetId()); 950 if (!comSession.isNull()) 962 /* Save snapshot name: */ 963 if (newData.m_strName != oldData.m_strName) 951 964 { 952 // TODO: Add settings save validation. 953 954 /* Save snapshot name: */ 955 if (newData.m_strName != oldData.m_strName) 956 comSnapshot.SetName(newData.m_strName); 957 /* Save snapshot description: */ 958 if (newData.m_strDescription != oldData.m_strDescription) 959 comSnapshot.SetDescription(newData.m_strDescription); 960 961 /* Close the session again: */ 962 comSession.UnlockMachine(); 965 comSnapshot.SetName(newData.m_strName); 966 if (!comSnapshot.isOk()) 967 { 968 msgCenter().cannotChangeSnapshot(comSnapshot, oldData.m_strName, comMachine.GetName()); 969 break; 970 } 971 } 972 973 /* Save snapshot description: */ 974 if (newData.m_strDescription != oldData.m_strDescription) 975 { 976 comSnapshot.SetDescription(newData.m_strDescription); 977 if (!comSnapshot.isOk()) 978 { 979 msgCenter().cannotChangeSnapshot(comSnapshot, oldData.m_strName, comMachine.GetName()); 980 break; 981 } 963 982 } 964 983 } 984 while (0); 985 986 /* Cleanup session: */ 987 comSession.UnlockMachine(); 965 988 } 966 } 967 968 /* Allows editing again: */969 m_pLockReadWrite->unlock();989 990 /* Allows editing again: */ 991 m_pLockReadWrite->unlock(); 992 } 970 993 971 994 /* Adjust snapshot tree: */
Note:
See TracChangeset
for help on using the changeset viewer.