Changeset 31579 in vbox for trunk/src/VBox/Frontends/VBoxHeadless
- Timestamp:
- Aug 11, 2010 5:21:27 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxHeadless/VBoxHeadless.cpp
r31539 r31579 83 83 static EventQueue *gEventQ = NULL; 84 84 85 /* flag whether frontend should terminate */ 86 static volatile bool g_fTerminateFE = false; 87 85 88 #ifdef VBOX_WITH_VNC 86 89 static VNCFB *g_pFramebufferVNC; … … 89 92 90 93 //////////////////////////////////////////////////////////////////////////////// 91 92 /**93 * State change event.94 */95 class StateChangeEvent : public Event96 {97 public:98 StateChangeEvent(MachineState_T state) : mState(state) {}99 protected:100 void *handler()101 {102 LogFlow(("VBoxHeadless: StateChangeEvent: %d\n", mState));103 /* post the termination event if the machine has been PoweredDown/Saved/Aborted */104 if (mState < MachineState_Running)105 gEventQ->postEvent(NULL);106 return 0;107 }108 private:109 MachineState_T mState;110 };111 94 112 95 /** … … 319 302 scev->COMGETTER(State)(&machineState); 320 303 321 gEventQ->postEvent(new StateChangeEvent(machineState)); 304 /* Terminate any event wait operation if the machine has been 305 * PoweredDown/Saved/Aborted. */ 306 if (machineState < MachineState_Running) 307 { 308 g_fTerminateFE = true; 309 gEventQ->interruptEventQueueProcessing(); 310 } 311 322 312 break; 323 313 } … … 1088 1078 break; 1089 1079 1090 /* Process pending events, then wait for new ones. */ 1080 /* Process pending events, then wait for new ones. Note, this 1081 * processes NULL events signalling event loop termination. */ 1091 1082 gEventQ->processEventQueue(0); 1092 gEventQ->processEventQueue(500); 1093 } 1094 1095 /** @todo The error handling here is kind of peculiar, anyone care 1096 * to comment why this works just fine? (this is old the code) */ 1083 if (!g_fTerminateFE) 1084 gEventQ->processEventQueue(500); 1085 } 1086 1097 1087 if (SUCCEEDED(progress->WaitForCompletion(-1))) 1098 1088 { 1089 /* Figure out if the operation completed with a failed status 1090 * and print the error message. Terminate immediately, and let 1091 * the cleanup code take care of potentially pending events. */ 1099 1092 LONG progressRc; 1100 1093 progress->COMGETTER(ResultCode)(&progressRc); 1101 1094 rc = progressRc; 1102 if (FAILED( progressRc))1095 if (FAILED(rc)) 1103 1096 { 1104 1097 com::ProgressErrorInfo info(progress); … … 1111 1104 RTPrintf("Error: failed to start machine. No error message available!\n"); 1112 1105 } 1106 break; 1113 1107 } 1114 1108 } … … 1132 1126 Log(("VBoxHeadless: Waiting for PowerDown...\n")); 1133 1127 1134 Event *e; 1135 1136 while (gEventQ->waitForEvent(&e) && e) 1137 gEventQ->handleEvent(e); 1128 while ( !g_fTerminateFE 1129 && RT_SUCCESS(gEventQ->processEventQueue(RT_INDEFINITE_WAIT))) 1130 /* nothing */ ; 1138 1131 1139 1132 Log(("VBoxHeadless: event loop has terminated...\n"));
Note:
See TracChangeset
for help on using the changeset viewer.