- Timestamp:
- Aug 25, 2021 5:15:36 PM (3 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/UICommon.cpp
r90795 r90893 2594 2594 } 2595 2595 2596 bool UICommon::restoreCurrentSnapshot(const QUuid &uMachineId) 2597 { 2598 /* Prepare result: */ 2599 bool fResult = false; 2600 2596 void UICommon::restoreCurrentSnapshot(const QUuid &uMachineId) 2597 { 2601 2598 /* Open a session to modify VM: */ 2602 2599 const bool fDirectSessionAvailable = (m_enmType == UIType_RuntimeUI) && isSeparateProcess(); … … 2654 2651 break; 2655 2652 } 2656 2657 /* Success: */2658 fResult = true;2659 2653 } 2660 2654 while (0); … … 2663 2657 comSession.UnlockMachine(); 2664 2658 } 2665 2666 /* Return result: */2667 return fResult;2668 2659 } 2669 2660 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UICommon.h
r90760 r90893 520 520 521 521 /** Restores current snapshot for machine with certain @a uMachineId. */ 522 boolrestoreCurrentSnapshot(const QUuid &uMachineId);522 void restoreCurrentSnapshot(const QUuid &uMachineId); 523 523 /** @} */ 524 524 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.cpp
r90728 r90893 1027 1027 } 1028 1028 1029 void UIMessageCenter::cannotPower DownMachine(const CConsole &comConsole) const1029 void UIMessageCenter::cannotPowerOffMachine(const CConsole &comConsole) const 1030 1030 { 1031 1031 error(0, MessageType_Error, … … 1035 1035 } 1036 1036 1037 void UIMessageCenter::cannotPower DownMachine(const CProgress &comProgress, const QString &strMachineName) const1037 void UIMessageCenter::cannotPowerOffMachine(const CProgress &comProgress, const QString &strMachineName) const 1038 1038 { 1039 1039 error(0, MessageType_Error, … … 2625 2625 if (fFatal) 2626 2626 { 2627 /* Power downafter a fFatal error: */2628 LogRel(("GUI: Powering VM downafter a fatal runtime error...\n"));2627 /* Power off after a fFatal error: */ 2628 LogRel(("GUI: Powering VM off after a fatal runtime error...\n")); 2629 2629 console1.PowerDown(); 2630 2630 } -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.h
r90728 r90893 310 310 void cannotPowerUpCloudMachine(const CCloudMachine &comMachine) const; 311 311 void cannotPowerUpCloudMachine(const CProgress &comProgress, const QString &strMachineName) const; 312 void cannotPower DownMachine(const CConsole &comConsole) const;313 void cannotPower DownMachine(const CProgress &comProgress, const QString &strMachineName) const;312 void cannotPowerOffMachine(const CConsole &comConsole) const; 313 void cannotPowerOffMachine(const CProgress &comProgress, const QString &strMachineName) const; 314 314 void cannotPowerDownCloudMachine(const CCloudMachine &comMachine) const; 315 315 void cannotPowerDownCloudMachine(const CProgress &comProgress, const QString &strMachineName) const; -
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.cpp
r90869 r90893 1819 1819 if (pItem->itemType() == UIVirtualMachineItemType_Local) 1820 1820 { 1821 /* Powering VM down: */1822 UINotificationProgressMachinePower Down*pNotification =1823 new UINotificationProgressMachinePower Down(pItem->toLocal()->machine());1821 /* Powering VM off: */ 1822 UINotificationProgressMachinePowerOff *pNotification = 1823 new UINotificationProgressMachinePowerOff(pItem->toLocal()->machine()); 1824 1824 gpNotificationCenter->append(pNotification); 1825 1825 } … … 1827 1827 else if (pItem->itemType() == UIVirtualMachineItemType_CloudReal) 1828 1828 { 1829 /* Powering cloud VM down: */1830 UINotificationProgressCloudMachinePower Down*pNotification =1831 new UINotificationProgressCloudMachinePower Down(pItem->toCloud()->machine());1829 /* Powering cloud VM off: */ 1830 UINotificationProgressCloudMachinePowerOff *pNotification = 1831 new UINotificationProgressCloudMachinePowerOff(pItem->toCloud()->machine()); 1832 1832 gpNotificationCenter->append(pNotification); 1833 1833 } -
trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.cpp
r90869 r90893 973 973 974 974 /********************************************************************************************************************************* 975 * Class UINotificationProgressMachinePower Down implementation.*976 *********************************************************************************************************************************/ 977 978 UINotificationProgressMachinePower Down::UINotificationProgressMachinePowerDown(const CMachine &comMachine)975 * Class UINotificationProgressMachinePowerOff implementation. * 976 *********************************************************************************************************************************/ 977 978 UINotificationProgressMachinePowerOff::UINotificationProgressMachinePowerOff(const CMachine &comMachine) 979 979 : m_comMachine(comMachine) 980 980 { 981 981 connect(this, &UINotificationProgress::sigProgressFinished, 982 this, &UINotificationProgressMachinePower Down::sltHandleProgressFinished);983 } 984 985 UINotificationProgressMachinePower Down::UINotificationProgressMachinePowerDown(const CConsole &comConsole)982 this, &UINotificationProgressMachinePowerOff::sltHandleProgressFinished); 983 } 984 985 UINotificationProgressMachinePowerOff::UINotificationProgressMachinePowerOff(const CConsole &comConsole) 986 986 : m_comConsole(comConsole) 987 987 { 988 988 connect(this, &UINotificationProgress::sigProgressFinished, 989 this, &UINotificationProgressMachinePower Down::sltHandleProgressFinished);990 } 991 992 QString UINotificationProgressMachinePower Down::name() const993 { 994 return UINotificationProgress::tr("Powering VM down...");995 } 996 997 QString UINotificationProgressMachinePower Down::details() const989 this, &UINotificationProgressMachinePowerOff::sltHandleProgressFinished); 990 } 991 992 QString UINotificationProgressMachinePowerOff::name() const 993 { 994 return UINotificationProgress::tr("Powering VM off ..."); 995 } 996 997 QString UINotificationProgressMachinePowerOff::details() const 998 998 { 999 999 return UINotificationProgress::tr("<b>VM Name:</b> %1").arg(m_strName); 1000 1000 } 1001 1001 1002 CProgress UINotificationProgressMachinePower Down::createProgress(COMResult &comResult)1002 CProgress UINotificationProgressMachinePowerOff::createProgress(COMResult &comResult) 1003 1003 { 1004 1004 /* Prepare machine to power off: */ … … 1086 1086 } 1087 1087 1088 void UINotificationProgressMachinePower Down::sltHandleProgressFinished()1088 void UINotificationProgressMachinePowerOff::sltHandleProgressFinished() 1089 1089 { 1090 1090 /* Unlock session finally: */ … … 1337 1337 1338 1338 /********************************************************************************************************************************* 1339 * Class UINotificationProgressCloudMachinePower Down implementation.*1340 *********************************************************************************************************************************/ 1341 1342 UINotificationProgressCloudMachinePower Down::UINotificationProgressCloudMachinePowerDown(const CCloudMachine &comMachine)1339 * Class UINotificationProgressCloudMachinePowerOff implementation. * 1340 *********************************************************************************************************************************/ 1341 1342 UINotificationProgressCloudMachinePowerOff::UINotificationProgressCloudMachinePowerOff(const CCloudMachine &comMachine) 1343 1343 : m_comMachine(comMachine) 1344 1344 { 1345 1345 } 1346 1346 1347 QString UINotificationProgressCloudMachinePower Down::name() const1348 { 1349 return UINotificationProgress::tr("Powering cloud VM down...");1350 } 1351 1352 QString UINotificationProgressCloudMachinePower Down::details() const1347 QString UINotificationProgressCloudMachinePowerOff::name() const 1348 { 1349 return UINotificationProgress::tr("Powering cloud VM off ..."); 1350 } 1351 1352 QString UINotificationProgressCloudMachinePowerOff::details() const 1353 1353 { 1354 1354 return UINotificationProgress::tr("<b>VM Name:</b> %1").arg(m_strName); 1355 1355 } 1356 1356 1357 CProgress UINotificationProgressCloudMachinePower Down::createProgress(COMResult &comResult)1357 CProgress UINotificationProgressCloudMachinePowerOff::createProgress(COMResult &comResult) 1358 1358 { 1359 1359 /* Acquire cloud VM name: */ -
trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.h
r90869 r90893 559 559 }; 560 560 561 /** UINotificationProgress extension for machine power- downfunctionality. */562 class SHARED_LIBRARY_STUFF UINotificationProgressMachinePower Down: public UINotificationProgress563 { 564 Q_OBJECT; 565 566 public: 567 568 /** Constructs machine power- downnotification-progress.561 /** UINotificationProgress extension for machine power-off functionality. */ 562 class SHARED_LIBRARY_STUFF UINotificationProgressMachinePowerOff : public UINotificationProgress 563 { 564 Q_OBJECT; 565 566 public: 567 568 /** Constructs machine power-off notification-progress. 569 569 * @param comMachine Brings the machine being powered off. */ 570 UINotificationProgressMachinePower Down(const CMachine &comMachine);571 /** Constructs machine power- downnotification-progress.570 UINotificationProgressMachinePowerOff(const CMachine &comMachine); 571 /** Constructs machine power-off notification-progress. 572 572 * @param comConsole Brings the console of machine being powered off. */ 573 UINotificationProgressMachinePower Down(const CConsole &comConsole);573 UINotificationProgressMachinePowerOff(const CConsole &comConsole); 574 574 575 575 protected: … … 826 826 }; 827 827 828 /** UINotificationProgress extension for cloud machine power- downfunctionality. */829 class SHARED_LIBRARY_STUFF UINotificationProgressCloudMachinePower Down: public UINotificationProgress830 { 831 Q_OBJECT; 832 833 public: 834 835 /** Constructs cloud machine power- downnotification-progress.836 * @param comMachine Brings the machine being powered- down. */837 UINotificationProgressCloudMachinePower Down(const CCloudMachine &comMachine);838 839 protected: 840 841 /** Returns object name. */ 842 virtual QString name() const /* override final */; 843 /** Returns object details. */ 844 virtual QString details() const /* override final */; 845 /** Creates and returns started progress-wrapper. */ 846 virtual CProgress createProgress(COMResult &comResult) /* override final */; 847 848 private: 849 850 /** Holds the machine being powered- down. */828 /** UINotificationProgress extension for cloud machine power-off functionality. */ 829 class SHARED_LIBRARY_STUFF UINotificationProgressCloudMachinePowerOff : public UINotificationProgress 830 { 831 Q_OBJECT; 832 833 public: 834 835 /** Constructs cloud machine power-off notification-progress. 836 * @param comMachine Brings the machine being powered-off. */ 837 UINotificationProgressCloudMachinePowerOff(const CCloudMachine &comMachine); 838 839 protected: 840 841 /** Returns object name. */ 842 virtual QString name() const /* override final */; 843 /** Returns object details. */ 844 virtual QString details() const /* override final */; 845 /** Creates and returns started progress-wrapper. */ 846 virtual CProgress createProgress(COMResult &comResult) /* override final */; 847 848 private: 849 850 /** Holds the machine being powered-off. */ 851 851 CCloudMachine m_comMachine; 852 852 /** Holds the machine name. */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp
r90890 r90893 386 386 #endif /* VBOX_WS_MAC */ 387 387 388 void UIMachineLogic::powerOff(bool fDiscardingState)389 {390 /* Enable 'manual-override',391 * preventing automatic Runtime UI closing: */392 uisession()->setManualOverrideMode(true);393 394 /* Was the step successful? */395 bool fSuccess = true;396 /* Power-off: */397 bool fServerCrashed = false;398 LogRel(("GUI: Passing request to power VM off from machine-logic to UI session.\n"));399 fSuccess = uisession()->powerOff(fDiscardingState, fServerCrashed) || fServerCrashed;400 401 /* Disable 'manual-override' finally: */402 uisession()->setManualOverrideMode(false);403 404 /* Manually close Runtime UI: */405 if (fSuccess)406 uisession()->closeRuntimeUI();407 }408 409 388 void UIMachineLogic::notifyAbout3DOverlayVisibilityChange(bool fVisible) 410 389 { … … 433 412 /* Power VM off: */ 434 413 LogRel(("GUI: Request to power VM off due to VBoxSVC is unavailable.\n")); 435 powerOff(false /* do NOT restore current snapshot */);414 uisession()->powerOff(false /* do NOT restore current snapshot */); 436 415 } 437 416 … … 488 467 if (msgCenter().remindAboutGuruMeditation(QDir::toNativeSeparators(strLogFolder))) 489 468 { 490 LogRel(("GUI: User request to power VM off on Guru Meditation.\n"));491 powerOff(false /* do NOT restore current snapshot */);469 LogRel(("GUI: User requested to power VM off on Guru Meditation.\n")); 470 uisession()->powerOff(false /* do NOT restore current snapshot */); 492 471 } 493 472 break; … … 497 476 { 498 477 LogRel(("GUI: Automatic request to power VM off on Guru Meditation.\n")); 499 powerOff(false /* do NOT restore current snapshot */);478 uisession()->powerOff(false /* do NOT restore current snapshot */); 500 479 break; 501 480 } … … 1885 1864 LogRel(("GUI: User requested to power VM off.\n")); 1886 1865 const bool fDiscardStateOnPowerOff = gEDataManager->discardStateOnPowerOff(uiCommon().managedVMUuid()); 1887 powerOff(machine().GetSnapshotCount() > 0 && fDiscardStateOnPowerOff);1866 uisession()->powerOff(machine().GetSnapshotCount() > 0 && fDiscardStateOnPowerOff); 1888 1867 } 1889 1868 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.h
r90890 r90893 142 142 virtual void updateDock(); 143 143 #endif /* VBOX_WS_MAC */ 144 145 /** Power off VM, then close Runtime UI. */146 void powerOff(bool fDiscardingState);147 144 148 145 /* API: 3D overlay visibility stuff: */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.cpp
r90890 r90893 470 470 LogRel(("GUI: Request for close-action to power VM off.\n")); 471 471 const bool fDiscardStateOnPowerOff = gEDataManager->discardStateOnPowerOff(uiCommon().managedVMUuid()); 472 machineLogic()->powerOff(machine().GetSnapshotCount() > 0 && fDiscardStateOnPowerOff);472 uisession()->powerOff(machine().GetSnapshotCount() > 0 && fDiscardStateOnPowerOff); 473 473 break; 474 474 } -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp
r90890 r90893 369 369 } 370 370 371 bool UISession::powerOff(bool fIncludingDiscard, bool &fServerCrashed) 372 { 371 void UISession::powerOff(bool fIncludingDiscard) 372 { 373 /* Prepare result: */ 374 bool fSuccess = false; 375 376 /* Enable 'manual-override', 377 * preventing automatic Runtime UI closing: */ 378 setManualOverrideMode(true); 379 373 380 /* Prepare the power-off progress: */ 374 LogRel(("GUI: Powering VM down on UI session power off request...\n")); 375 CProgress progress = console().PowerDown(); 376 if (console().isOk()) 381 LogRel(("GUI: Powering VM off..\n")); 382 CProgress comProgress = console().PowerDown(); 383 if (!console().isOk()) 384 { 385 /* Check the console state, it might be already gone: */ 386 if (!console().isNull()) 387 { 388 /* This can happen if VBoxSVC is not running: */ 389 COMResult res(console()); 390 if (FAILED_DEAD_INTERFACE(res.rc())) 391 fSuccess = true; 392 } 393 394 if (!fSuccess) 395 msgCenter().cannotPowerOffMachine(console()); 396 } 397 else 377 398 { 378 399 /* Show the power-off progress: */ 379 msgCenter().showModalProgressDialog(progress, machineName(), ":/progress_poweroff_90px.png"); 380 if (progress.isOk() && progress.GetResultCode() == 0) 381 { 400 msgCenter().showModalProgressDialog(comProgress, machineName(), ":/progress_poweroff_90px.png"); 401 if (comProgress.isOk() && comProgress.GetResultCode() == 0) 402 { 403 fSuccess = true; 404 382 405 /* Discard the current state if requested: */ 383 406 if (fIncludingDiscard) 384 returnuiCommon().restoreCurrentSnapshot(uiCommon().managedVMUuid());407 uiCommon().restoreCurrentSnapshot(uiCommon().managedVMUuid()); 385 408 } 386 409 else 387 { 388 /* Failed in progress: */ 389 msgCenter().cannotPowerDownMachine(progress, machineName()); 390 return false; 391 } 392 } 393 else 394 { 395 /* Check the machine state, it might be already gone: */ 396 if (!console().isNull()) 397 { 398 /* Failed in console: */ 399 COMResult res(console()); 400 /* This can happen if VBoxSVC is not running: */ 401 if (FAILED_DEAD_INTERFACE(res.rc())) 402 fServerCrashed = true; 403 else 404 msgCenter().cannotPowerDownMachine(console()); 405 return false; 406 } 407 } 408 /* Passed: */ 409 return true; 410 msgCenter().cannotPowerOffMachine(comProgress, machineName()); 411 } 412 413 /* Disable 'manual-override' finally: */ 414 setManualOverrideMode(false); 415 416 /* Manually close Runtime UI: */ 417 if (fSuccess) 418 closeRuntimeUI(); 410 419 } 411 420 … … 1960 1969 setManualOverrideMode(true); 1961 1970 /* Power off VM: */ 1962 bool fServerCrashed = false;1963 1971 LogRel(("GUI: Aborting startup due to postprocess initialization issue detected...\n")); 1964 powerOff(false /* do NOT restore current snapshot */ , fServerCrashed);1972 powerOff(false /* do NOT restore current snapshot */); 1965 1973 return false; 1966 1974 } -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h
r90890 r90893 83 83 /** Calls for guest shutdown to close Runtime UI. */ 84 84 void shutdown(); 85 /** Powers VM down, then closes Runtime UI. */86 bool powerOff(bool fIncludingDiscard, bool &fServerCrashed);85 /** Powers VM off, then closes Runtime UI. */ 86 void powerOff(bool fIncludingDiscard); 87 87 88 88 /** Returns the session instance. */
Note:
See TracChangeset
for help on using the changeset viewer.