Changeset 26898 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Feb 28, 2010 7:46:25 PM (15 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/runtime
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp
r26896 r26898 587 587 m_pRunningOrPausedActions->setEnabled(uisession()->isRunning() || uisession()->isPaused()); 588 588 589 /* Do we have GURU? */590 bool fIsGuruMeditation = false;591 592 589 switch (state) 593 590 { 594 case KMachineState_Stuck: 595 { 596 /* We will process GURU later: */ 597 fIsGuruMeditation = true; 591 case KMachineState_Stuck: // TODO: Test it! 592 { 593 /* Prevent machine view from resizing: */ 594 uisession()->setGuestResizeIgnored(true); 595 596 /* Get console: */ 597 CConsole console = session().GetConsole(); 598 599 /* Take the screenshot for debugging purposes and save it */ 600 QString strLogFolder = console.GetMachine().GetLogFolder(); 601 QString strFileName = strLogFolder + "/VBox.png"; 602 CDisplay display = console.GetDisplay(); 603 QImage shot = QImage(display.GetWidth(), display.GetHeight(), QImage::Format_RGB32); 604 display.TakeScreenShot(shot.bits(), shot.width(), shot.height()); 605 shot.save(QFile::encodeName(strFileName), "PNG"); 606 607 /* Warn the user about GURU: */ 608 if (vboxProblem().remindAboutGuruMeditation(console, QDir::toNativeSeparators(strLogFolder))) 609 { 610 console.PowerDown(); 611 if (!console.isOk()) 612 vboxProblem().cannotStopMachine(console); 613 } 598 614 break; 599 615 } … … 625 641 break; 626 642 } 643 case KMachineState_PoweredOff: 644 case KMachineState_Saved: 645 case KMachineState_Teleported: 646 case KMachineState_Aborted: 647 { 648 /* Close VM if it was turned off and closure allowed: */ 649 if (!isPreventAutoClose()) 650 { 651 /* VM has been powered off, saved or aborted, no matter 652 * internally or externally. We must *safely* close VM window(s): */ 653 QTimer::singleShot(0, uisession(), SLOT(sltCloseVirtualSession())); 654 } 655 break; 656 } 627 657 #ifdef Q_WS_X11 628 658 case KMachineState_Starting: … … 639 669 break; 640 670 } 641 642 /* Close VM if was closed someway: */643 if (uisession()->isTurnedOff())644 {645 /* VM has been powered off or saved or aborted, no matter internally or externally.646 * We must *safely* close the console window unless auto closure is disabled: */647 QTimer::singleShot(0, uisession(), SLOT(sltCloseVirtualSession()));648 return;649 }650 651 #if 0 // TODO: Postprocess GURU!652 if (fIsGuruMeditation)653 {654 uisession()->setGuestResizeIgnored(true);655 656 CConsole console = session().GetConsole();657 QString strLogFolder = console.GetMachine().GetLogFolder();658 659 /* Take the screenshot for debugging purposes and save it */660 QString strFileName = strLogFolder + "/VBox.png";661 CDisplay display = console.GetDisplay();662 QImage shot = QImage(display.GetWidth(), display.GetHeight(), QImage::Format_RGB32);663 display.TakeScreenShot(shot.bits(), shot.width(), shot.height());664 shot.save(QFile::encodeName(strFileName), "PNG");665 666 /* Warn the user about GURU: */667 if (vboxProblem().remindAboutGuruMeditation(console, QDir::toNativeSeparators(strLogFolder)))668 {669 qApp->processEvents();670 console.PowerDown();671 if (!console.isOk())672 vboxProblem().cannotStopMachine(console);673 }674 }675 #endif676 671 } 677 672 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.cpp
r26892 r26898 130 130 void UIMachineWindow::closeEvent(QCloseEvent *pEvent) 131 131 { 132 /* Always ignore close event: */ 133 pEvent->ignore(); 134 135 /* Should we close application? */ 136 bool fCloseApplication = false; 137 132 138 switch (uisession()->machineState()) 133 139 { … … 139 145 case KMachineState_TeleportingPausedVM: // TODO: Test this! 140 146 { 141 /* Ignoring close event initially: */142 pEvent->ignore();143 144 147 bool success = true; 148 149 /* Get the ACPI status early before pausing VM: */ 150 bool isACPIEnabled = session().GetConsole().GetGuestEnteredACPIMode(); 145 151 146 152 bool fWasPaused = uisession()->isPaused() || uisession()->machineState() == KMachineState_Stuck; … … 156 162 success = false; 157 163 164 /* Preventing closure right after we had paused: */ 165 machineLogic()->setPreventAutoClose(true); 166 158 167 /* Get the machine: */ 159 168 CMachine machine = session().GetMachine(); 160 161 /* Get the ACPI status: */162 bool isACPIEnabled = session().GetConsole().GetGuestEnteredACPIMode();163 169 164 170 /* Prepare close dialog: */ … … 172 178 dlg.mCbDiscardCurState->setText(dlg.mCbDiscardCurState->text().arg(machine.GetCurrentSnapshot().GetName())); 173 179 174 /* C lose choice string tags: */180 /* Choice string tags for close-dialog: */ 175 181 QString strSave("save"); 176 182 QString strShutdown("shutdown"); … … 284 290 } 285 291 286 if (success)287 {288 /* Accept the close action on success: */289 pEvent->accept();290 }291 292 292 if (success || fWasShutdown) 293 293 { … … 310 310 AssertWrapperOk(machine); 311 311 } 312 313 fCloseApplication = success; 312 314 } 313 315 } 314 316 315 if (uisession()->machineState() == KMachineState_PoweredOff || 316 uisession()->machineState() == KMachineState_Saved || 317 uisession()->machineState() == KMachineState_Teleported || 318 uisession()->machineState() == KMachineState_Aborted) 317 if (!success) 319 318 { 320 /* The machine has been stopped while showing the Close or the Pause 321 * failure dialog - accept the close event immediately: */ 322 pEvent->accept(); 323 } 324 else 325 { 326 if (!success) 327 { 328 /* Restore the running state if needed: */ 329 if (!fWasPaused && uisession()->machineState() == KMachineState_Paused) 330 uisession()->unpause(); 331 } 319 /* Restore the running state if needed: */ 320 if (!fWasPaused && uisession()->machineState() == KMachineState_Paused) 321 uisession()->unpause(); 332 322 } 333 323 break; 334 324 } 335 325 336 #if 0 // TODO: Check if all those states processing is really needed: 337 case KMachineState_PoweredOff: 338 case KMachineState_Saved: 339 case KMachineState_Teleported: 340 case KMachineState_Aborted: 341 { 342 /* The machine has been already powered off or saved or aborted - close the window immediately: */ 343 pEvent->accept(); 326 default: 344 327 break; 345 }346 #endif347 348 default:349 {350 /* The machine is in some temporary state like Saving or Stopping.351 * Ignore the close event. It will be processed later if something will be failed: */352 pEvent->ignore();353 break;354 }355 328 } 356 329 357 /* Postprocess event if accepted: */ 358 if (pEvent->isAccepted()) 330 /* Allowing closure: */ 331 machineLogic()->setPreventAutoClose(false); 332 333 if (fCloseApplication) 359 334 { 360 #ifndef VBOX_GUI_SEPARATE_VM_PROCESS 361 vboxGlobal().selectorWnd().show(); 362 #endif 363 364 #ifdef VBOX_WITH_DEBUGGER_GUI 365 /* Close & destroy the debugger GUI */ 366 // TODO: Check that logic! 367 //dbgDestroy(); 368 #endif 369 370 /* Notify all the top-level child dialogs about closing: */ 371 // TODO: Notify about closing! 372 //emit closing(); 373 374 /* Reject that event finally as uimachine will close window iteself: */ 375 pEvent->ignore(); 376 377 /* Request uisession closing: */ 335 /* VM has been powered off or saved. We must *safely* close the VM window(s): */ 378 336 QTimer::singleShot(0, uisession(), SLOT(sltCloseVirtualSession())); 379 337 }
Note:
See TracChangeset
for help on using the changeset viewer.