- Timestamp:
- Oct 6, 2016 12:03:52 PM (8 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp
r63694 r64160 147 147 #include <QSettings> 148 148 #include <QStyleOptionSpinBox> 149 #include <QSessionManager> 149 150 150 151 /* Other VBox includes: */ … … 3899 3900 /* Make sure QApplication cleanup us on exit: */ 3900 3901 connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(cleanup())); 3902 /* Make sure we handle host OS session shutdown as well: */ 3903 connect(qApp, SIGNAL(commitDataRequest(QSessionManager &)), 3904 this, SLOT(sltHandleCommitDataRequest(QSessionManager &))); 3901 3905 3902 3906 #ifdef VBOX_WS_MAC … … 4413 4417 } 4414 4418 4419 #ifdef VBOX_WS_WIN 4420 /* static */ 4421 BOOL VBoxGlobal::ShutdownBlockReasonCreateAPI(HWND hWnd, LPCWSTR pwszReason) 4422 { 4423 BOOL fResult = FALSE; 4424 typedef BOOL(WINAPI *PFNSHUTDOWNBLOCKREASONCREATE)(HWND hWnd, LPCWSTR pwszReason); 4425 4426 PFNSHUTDOWNBLOCKREASONCREATE pfn = (PFNSHUTDOWNBLOCKREASONCREATE)GetProcAddress( 4427 GetModuleHandle(L"User32.dll"), "ShutdownBlockReasonCreate"); 4428 _ASSERTE(pfn); 4429 if (pfn) 4430 fResult = pfn(hWnd, pwszReason); 4431 return fResult; 4432 } 4433 #endif 4434 4435 void VBoxGlobal::sltHandleCommitDataRequest(QSessionManager &manager) 4436 { 4437 LogRel(("GUI: VBoxGlobal::sltHandleCommitDataRequest: Emergency shutdown initiated\n")); 4438 4439 /* For VM process: */ 4440 if (vboxGlobal().isVMConsoleProcess()) 4441 { 4442 /* Temporary override the default close action to 'SaveState' if necessary: */ 4443 if (gpMachine->uisession()->defaultCloseAction() == MachineCloseAction_Invalid) 4444 gpMachine->uisession()->setDefaultCloseAction(MachineCloseAction_SaveState); 4445 } 4446 4447 /* Ask session manager to postpone shutdown until we done: */ 4448 manager.cancel(); 4449 4450 #ifdef VBOX_WS_WIN 4451 // WORKAROUND: 4452 // In theory that's Qt5 who should allow us to provide postponing reason as well, 4453 // but that functionality seems missed in Windows platform plugin, so we are making that ourselves. 4454 // That also implies that since we had postponed a shutdown process, host will send us WM_QUIT to 4455 // allow to properly do an application cleanup first. That signal will cause QApplication to quit(). 4456 ShutdownBlockReasonCreateAPI((HWND)windowManager().mainWindowShown()->winId(), L"Shutdown in progress..."); 4457 #endif 4458 } 4459 4415 4460 void VBoxGlobal::sltHandleVBoxSVCAvailabilityChange(bool fAvailable) 4416 4461 { -
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h
r63054 r64160 469 469 void cleanup(); 470 470 471 /** Handles @a manager request for emergency session shutdown. */ 472 void sltHandleCommitDataRequest(QSessionManager &manager); 473 471 474 /** Shows UI. */ 472 475 void showUI(); … … 487 490 /** Re-initializes COM wrappers and containers. */ 488 491 void comWrappersReinit(); 492 493 #ifdef VBOX_WS_WIN 494 /** Wraps WinAPI ShutdownBlockReasonCreate function. 495 * @remark This function defined starting from Vista only. */ 496 static BOOL ShutdownBlockReasonCreateAPI(HWND hWnd, LPCWSTR pwszReason); 497 #endif 489 498 490 499 #ifdef VBOX_WITH_DEBUGGER_GUI -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h
r62493 r64160 146 146 /** @name Application Close configuration stuff. 147 147 * @{ */ 148 /** Defines @a defaultCloseAction. */ 149 void setDefaultCloseAction(MachineCloseAction defaultCloseAction) { m_defaultCloseAction = defaultCloseAction; } 148 150 /** Returns default close action. */ 149 151 MachineCloseAction defaultCloseAction() const { return m_defaultCloseAction; } -
trunk/src/VBox/Main/src-server/win/svcmain.cpp
r63549 r64160 155 155 BOOL ShutdownBlockReasonCreateAPI(HWND hWnd,LPCWSTR pwszReason) 156 156 { 157 BOOL result = FALSE;157 BOOL fResult = FALSE; 158 158 typedef BOOL(WINAPI *PFNSHUTDOWNBLOCKREASONCREATE)(HWND hWnd, LPCWSTR pwszReason); 159 159 … … 162 162 _ASSERTE(pfn); 163 163 if (pfn) 164 result = pfn(hWnd, pwszReason);165 return result;164 fResult = pfn(hWnd, pwszReason); 165 return fResult; 166 166 } 167 167 … … 172 172 BOOL ShutdownBlockReasonDestroyAPI(HWND hWnd) 173 173 { 174 BOOL result = FALSE;174 BOOL fResult = FALSE; 175 175 typedef BOOL(WINAPI *PFNSHUTDOWNBLOCKREASONDESTROY)(HWND hWnd); 176 176 … … 179 179 _ASSERTE(pfn); 180 180 if (pfn) 181 result = pfn(hWnd);182 return result;181 fResult = pfn(hWnd); 182 return fResult; 183 183 } 184 184 … … 198 198 /* decrease a latency of MonitorShutdown loop */ 199 199 ASMAtomicXchgU32(&dwTimeOut, 100); 200 Log(("VBoxSVCWinMain: VBoxSvc has active connections. bActivity = %d. Loc count = %d\n",200 Log(("VBoxSVCWinMain: WM_QUERYENDSESSION: VBoxSvc has active connections. bActivity = %d. Loc count = %d\n", 201 201 _Module.bActivity, _Module.GetLockCount())); 202 202 } 203 Log(("VBoxSVCWinMain: WM_QUERYENDSESSION msg: %d rc= %d\n", msg, rc)); 204 } break; 203 } break; 205 204 case WM_ENDSESSION: 206 205 { … … 211 210 Log(("VBoxSVCWinMain: user canceled system shutdown.\n")); 212 211 } 213 Log(("VBoxSVCWinMain: WM_ENDSESSION msg: %d. wParam: %d. lParam: %d\n", msg, wParam, lParam));214 212 } break; 215 213 case WM_DESTROY: 216 214 { 217 Log(("VBoxSVCWinMain: WM_DESTROY \n"));218 215 ShutdownBlockReasonDestroyAPI(hwnd); 219 216 PostQuitMessage(0); … … 222 219 default: 223 220 { 224 Log(("VBoxSVCWinMain: msg %p\n", msg));225 221 rc = DefWindowProc(hwnd, msg, wParam, lParam); 226 222 }
Note:
See TracChangeset
for help on using the changeset viewer.