- Timestamp:
- Mar 28, 2013 10:12:52 AM (12 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/runtime
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.cpp
r45167 r45224 488 488 } 489 489 490 void UIMachine::sltCloseVirtualMachine()491 {492 delete this;493 }494 495 490 void UIMachine::enterInitialVisualState() 496 491 { -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.h
r44529 r45224 55 55 void sltChangeVisualState(UIVisualStateType visualStateType); 56 56 57 /* Close VM slot: */58 void sltCloseVirtualMachine();59 60 57 private: 61 58 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp
r45193 r45224 361 361 case KMachineState_Aborted: 362 362 { 363 /* Close VM if it was turned off and closure allowed:*/363 /* Is it allowed to close Runtime UI? */ 364 364 if (!isPreventAutoClose()) 365 365 { 366 /* VM has been powered off, saved or aborted, no matter367 * internally or externally. We must *safely* close VM window(s): */368 QTimer::singleShot(0, uisession(), SLOT(sltCloseVirtualSession()));366 /* VM has been powered off, saved, teleported or aborted. 367 * We must close Runtime UI: */ 368 uisession()->closeRuntimeUI(); 369 369 } 370 370 break; -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.cpp
r45213 r45224 251 251 pEvent->ignore(); 252 252 253 /* Should we shutdown UI session? */254 bool f ShutdownSession= false;253 /* Should we close Runtime UI? */ 254 bool fCloseRuntimeUI = false; 255 255 256 256 /* Make sure machine is in one of the allowed states: */ … … 320 320 { 321 321 fSuccess = uisession()->saveState(); 322 f ShutdownSession= fSuccess;322 fCloseRuntimeUI = fSuccess; 323 323 break; 324 324 } … … 336 336 fSuccess = uisession()->powerOff(dialogResult == UIVMCloseDialog::ResultCode_PowerOff_With_Discarding, 337 337 fServerCrashed); 338 f ShutdownSession= fSuccess || fServerCrashed;338 fCloseRuntimeUI = fSuccess || fServerCrashed; 339 339 break; 340 340 } … … 345 345 346 346 /* Restore the running state if needed: */ 347 if (fSuccess && !f ShutdownSession&& !fWasPaused && uisession()->machineState() == KMachineState_Paused)347 if (fSuccess && !fCloseRuntimeUI && !fWasPaused && uisession()->machineState() == KMachineState_Paused) 348 348 uisession()->unpause(); 349 349 … … 352 352 } 353 353 354 if (fShutdownSession) 355 { 356 /* VM has been powered off or saved. We must *safely* close VM window(s): */ 357 QTimer::singleShot(0, uisession(), SLOT(sltCloseVirtualSession())); 358 } 354 /* We've received a request to close Runtime UI: */ 355 if (fCloseRuntimeUI) 356 uisession()->closeRuntimeUI(); 359 357 } 360 358 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp
r45213 r45224 22 22 #include <QDesktopWidget> 23 23 #include <QWidget> 24 #include <QTimer>25 24 26 25 /* GUI includes: */ … … 211 210 if (vboxGlobal().showStartVMErrors()) 212 211 msgCenter().cannotStartMachine(console); 213 QTimer::singleShot(0, this, SLOT(sltCloseVirtualSession()));212 closeRuntimeUI(); 214 213 return; 215 214 } … … 236 235 if (vboxGlobal().showStartVMErrors()) 237 236 msgCenter().cannotStartMachine(progress); 238 QTimer::singleShot(0, this, SLOT(sltCloseVirtualSession()));237 closeRuntimeUI(); 239 238 return; 240 239 } … … 247 246 if (isTurnedOff()) 248 247 { 249 QTimer::singleShot(0, this, SLOT(sltCloseVirtualSession()));248 closeRuntimeUI(); 250 249 return; 251 250 } … … 291 290 else 292 291 msgCenter().cannotStopMachine(console); 293 /* Now signal the destruction of the rest. */ 294 QTimer::singleShot(0, this, SLOT(sltCloseVirtualSession())); 292 closeRuntimeUI(); 295 293 return; 296 294 } … … 427 425 } 428 426 427 void UISession::closeRuntimeUI() 428 { 429 /* Start corresponding slot asynchronously: */ 430 emit sigCloseRuntimeUI(); 431 } 432 429 433 UIMachineLogic* UISession::machineLogic() const 430 434 { … … 601 605 } 602 606 603 void UISession::sltClose VirtualSession()604 { 605 /* First, we have to close/hide any opened modal & popup applicationwidgets.606 * We have to make sure such window is hidden even if close-event was rejected.607 * We are re-throwing this slot if any widget present to test again.608 * If all opened widgets are closed/hidden, we can try to close machine-window: */609 QWidget *pWidget = QApplication::activeModalWidget() ?QApplication::activeModalWidget() :610 QApplication::activePopupWidget() ? QApplication::activePopupWidget() : 0;611 if (pWidget)612 { 613 /* Closing/hiding all we found: */607 void UISession::sltCloseRuntimeUI() 608 { 609 /* First, we have to hide any opened modal/popup widgets. 610 * They then should unlock their event-loops synchronously. 611 * If all such loops are unlocked, we can close Runtime UI: */ 612 if (QWidget *pWidget = QApplication::activeModalWidget() ? 613 QApplication::activeModalWidget() : 614 QApplication::activePopupWidget() ? 615 QApplication::activePopupWidget() : 0) 616 { 617 /* First we should try to close this widget: */ 614 618 pWidget->close(); 619 /* If widget rejected the 'close-event' we can 620 * still hide it and hope it will behave correctly 621 * and unlock his event-loop if any: */ 615 622 if (!pWidget->isHidden()) 616 623 pWidget->hide(); 617 QTimer::singleShot(0, this, SLOT(sltCloseVirtualSession())); 624 /* Restart this slot asynchronously: */ 625 emit sigCloseRuntimeUI(); 618 626 return; 619 627 } 620 628 621 /* Recursively close all the opened warnings... */ 622 if (msgCenter().isAnyWarningShown()) 623 { 624 msgCenter().closeAllWarnings(); 625 QTimer::singleShot(0, this, SLOT(sltCloseVirtualSession())); 626 return; 627 } 628 629 /* Finally, ask for closing virtual machine: */ 630 QTimer::singleShot(0, m_pMachine, SLOT(sltCloseVirtualMachine())); 629 /* Finally close the Runtime UI: */ 630 m_pMachine->deleteLater(); 631 631 } 632 632 … … 845 845 void UISession::prepareConnections() 846 846 { 847 connect(this, SIGNAL(sigCloseRuntimeUI()), this, SLOT(sltCloseRuntimeUI())); 848 847 849 connect(QApplication::desktop(), SIGNAL(screenCountChanged(int)), 848 850 this, SIGNAL(sigHostScreenCountChanged(int))); … … 1366 1368 else 1367 1369 { 1368 QTimer::singleShot(0, this, SLOT(sltCloseVirtualSession()));1370 closeRuntimeUI(); 1369 1371 return false; 1370 1372 } -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h
r45213 r45224 87 87 virtual ~UISession(); 88 88 89 /* Common members: */89 /* API: Runtime UI stuff: */ 90 90 void powerUp(); 91 91 bool saveState(); 92 92 bool shutDown(); 93 93 bool powerOff(bool fIncludingDiscard, bool &fServerCrashed); 94 void closeRuntimeUI(); 94 95 95 96 /* Common getters: */ … … 167 168 168 169 signals: 170 171 /* Notifier: Close Runtime UI stuff: */ 172 void sigCloseRuntimeUI(); 169 173 170 174 /* Console callback signals: */ … … 199 203 private slots: 200 204 201 /* Close uisession handler: */202 void sltClose VirtualSession();205 /* Handler: Close Runtime UI stuff: */ 206 void sltCloseRuntimeUI(); 203 207 204 208 /* Console events slots */
Note:
See TracChangeset
for help on using the changeset viewer.