Changeset 90086 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Jul 8, 2021 8:51:06 AM (4 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/UICommon.cpp
r89298 r90086 2626 2626 } 2627 2627 2628 bool UICommon::restoreCurrentSnapshot(const QUuid &uMachineId) 2629 { 2630 /* Prepare result: */ 2631 bool fResult = false; 2632 2633 /* Open a session to modify VM: */ 2634 const bool fDirectSessionAvailable = (m_enmType == UIType_RuntimeUI) && isSeparateProcess(); 2635 CSession comSession = openSession(uMachineId, fDirectSessionAvailable ? KLockType_Write : KLockType_Shared); 2636 if (!comSession.isNull()) 2637 { 2638 /* Simulate try-catch block: */ 2639 do 2640 { 2641 /* Acquire session machine: */ 2642 CMachine comMachine = comSession.GetMachine(); 2643 if (!comSession.isOk()) 2644 { 2645 msgCenter().cannotAcquireSessionParameter(comSession); 2646 break; 2647 } 2648 2649 /* Acquire machine name: */ 2650 const QString strMachineName = comMachine.GetName(); 2651 if (!comMachine.isOk()) 2652 { 2653 msgCenter().cannotAcquireMachineParameter(comMachine); 2654 break; 2655 } 2656 2657 /* Acquire current snapshot: */ 2658 const CSnapshot comSnapshot = comMachine.GetCurrentSnapshot(); 2659 if (!comMachine.isOk()) 2660 { 2661 msgCenter().cannotAcquireMachineParameter(comMachine); 2662 break; 2663 } 2664 2665 /* Acquire snapshot name: */ 2666 const QString strSnapshotName = comSnapshot.GetName(); 2667 if (!comSnapshot.isOk()) 2668 { 2669 msgCenter().cannotAcquireSnapshotParameter(comSnapshot); 2670 break; 2671 } 2672 2673 /* Prepare the snapshot-discard progress: */ 2674 CProgress comProgress = comMachine.RestoreSnapshot(comSnapshot); 2675 if (!comMachine.isOk()) 2676 { 2677 msgCenter().cannotRestoreSnapshot(comMachine, strSnapshotName, strMachineName); 2678 break; 2679 } 2680 2681 /* Show the snapshot-discard progress: */ 2682 msgCenter().showModalProgressDialog(comProgress, comMachine.GetName(), ":/progress_snapshot_discard_90px.png"); 2683 if (comProgress.GetResultCode() != 0) 2684 { 2685 msgCenter().cannotRestoreSnapshot(comProgress, strSnapshotName, strMachineName); 2686 break; 2687 } 2688 2689 /* Success: */ 2690 fResult = true; 2691 } 2692 while (0); 2693 2694 /* Unlock machine finally: */ 2695 comSession.UnlockMachine(); 2696 } 2697 2698 /* Return result: */ 2699 return fResult; 2700 } 2701 2628 2702 void UICommon::notifyCloudMachineUnregistered(const QString &strProviderShortName, 2629 2703 const QString &strProfileName, -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UICommon.h
r89298 r90086 510 510 * otherwise, no session will be created and machine will be left unchanged. */ 511 511 CSession tryToOpenSessionFor(CMachine &comMachine); 512 513 /** Restores current snapshot for machine with certain @a uMachineId. */ 514 bool restoreCurrentSnapshot(const QUuid &uMachineId); 512 515 /** @} */ 513 516 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.cpp
r89968 r90086 620 620 } 621 621 622 void UIMessageCenter::cannotAcquireSessionParameter(const CSession &comSession, QWidget *pParent /* = 0 */) const 623 { 624 /* Show the error: */ 625 error(pParent, MessageType_Error, 626 tr("Failed to acquire session parameter."), UIErrorString::formatErrorInfo(comSession)); 627 } 628 622 629 void UIMessageCenter::cannotAcquireMachineParameter(const CMachine &comMachine, QWidget *pParent /* = 0 */) const 623 630 { … … 625 632 error(pParent, MessageType_Error, 626 633 tr("Failed to acquire machine parameter."), UIErrorString::formatErrorInfo(comMachine)); 634 } 635 636 void UIMessageCenter::cannotAcquireSnapshotParameter(const CSnapshot &comSnapshot, QWidget *pParent /* = 0 */) const 637 { 638 /* Show the error: */ 639 error(pParent, MessageType_Error, 640 tr("Failed to acquire snapshot parameter."), UIErrorString::formatErrorInfo(comSnapshot)); 627 641 } 628 642 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.h
r89968 r90086 273 273 void warnAboutInvalidEncryptionPassword(const QString &strPasswordId, QWidget *pParent = 0); 274 274 void cannotAcquireVirtualBoxParameter(const CVirtualBox &comVBox, QWidget *pParent = 0) const; 275 void cannotAcquireSessionParameter(const CSession &comSession, QWidget *pParent = 0) const; 275 276 void cannotAcquireMachineParameter(const CMachine &comMachine, QWidget *pParent = 0) const; 277 void cannotAcquireSnapshotParameter(const CSnapshot &comSnapshot, QWidget *pParent = 0) const; 276 278 void cannotFindHelpFile(const QString &strFileLocation) const; 277 279 void cannotEnumerateHostUSBDevices(const CHost &comHost, QWidget *pParent = 0) const; -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp
r90083 r90086 379 379 /* Discard the current state if requested: */ 380 380 if (fIncludingDiscard) 381 return restoreCurrentSnapshot();381 return uiCommon().restoreCurrentSnapshot(uiCommon().managedVMUuid()); 382 382 } 383 383 else … … 405 405 /* Passed: */ 406 406 return true; 407 }408 409 bool UISession::restoreCurrentSnapshot()410 {411 /* Prepare result: */412 bool fResult = false;413 414 /* Simulate try-catch block: */415 do416 {417 /* Search for corresponding VM: */418 CVirtualBox vbox = uiCommon().virtualBox();419 const QUuid uMachineID = uiCommon().managedVMUuid();420 const CMachine mach = vbox.FindMachine(uMachineID.toString());421 if (!vbox.isOk() || mach.isNull())422 {423 /* Unable to find VM: */424 msgCenter().cannotFindMachineById(vbox, uMachineID);425 break;426 }427 428 /* Open a direct session to modify that VM: */429 CSession sess = uiCommon().openSession(uiCommon().managedVMUuid(),430 uiCommon().isSeparateProcess()431 ? KLockType_Write : KLockType_Shared);432 if (sess.isNull())433 {434 /* Unable to open session: */435 break;436 }437 438 /* Simulate try-catch block: */439 do440 {441 /* Acquire machine for this session: */442 CMachine machine = sess.GetMachine();443 if (machine.isNull())444 {445 /* Unable to acquire machine: */446 break;447 }448 449 /* Prepare the snapshot-discard progress: */450 const CSnapshot snap = machine.GetCurrentSnapshot();451 CProgress prog = machine.RestoreSnapshot(snap);452 if (!machine.isOk() || prog.isNull())453 {454 /* Unable to restore snapshot: */455 msgCenter().cannotRestoreSnapshot(machine, snap.GetName(), machineName());456 break;457 }458 459 /* Show the snapshot-discard progress: */460 msgCenter().showModalProgressDialog(prog, machine.GetName(), ":/progress_snapshot_discard_90px.png");461 if (prog.GetResultCode() != 0)462 {463 /* Unable to restore snapshot: */464 msgCenter().cannotRestoreSnapshot(prog, snap.GetName(), machine.GetName());465 break;466 }467 468 /* Success: */469 fResult = true;470 }471 while (0);472 473 /* Unlock machine finally: */474 sess.UnlockMachine();475 }476 while (0);477 478 /* Return result: */479 return fResult;480 407 } 481 408 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h
r88685 r90086 80 80 bool shutdown(); 81 81 bool powerOff(bool fIncludingDiscard, bool &fServerCrashed); 82 bool restoreCurrentSnapshot();83 82 84 83 /** Returns the session instance. */
Note:
See TracChangeset
for help on using the changeset viewer.