Changeset 53000 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Oct 8, 2014 4:55:32 PM (10 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/runtime
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.cpp
r52995 r53000 32 32 /* COM includes: */ 33 33 # include "CMachine.h" 34 # include "CSession.h" 34 35 # include "CConsole.h" 35 36 # include "CSnapshot.h" … … 150 151 } 151 152 153 /* Try to create machine UI: */ 154 return create(); 155 } 156 157 /* static */ 158 bool UIMachine::create() 159 { 160 /* Make sure machine is null pointer: */ 161 AssertReturn(m_spInstance == 0, false); 162 152 163 /* Create machine UI: */ 153 164 new UIMachine; 154 /* Prepare machine UI: */ 155 return m_spInstance->prepare(); 165 /* Make sure it's prepared: */ 166 if (!m_spInstance->prepare()) 167 { 168 /* Destroy machine UI otherwise: */ 169 destroy(); 170 /* False in that case: */ 171 return false; 172 } 173 /* True by default: */ 174 return true; 156 175 } 157 176 … … 159 178 void UIMachine::destroy() 160 179 { 180 /* Make sure machine is valid pointer: */ 181 AssertReturnVoid(m_spInstance != 0); 182 161 183 /* Cleanup machine UI: */ 162 184 m_spInstance->cleanup(); … … 229 251 bool UIMachine::prepare() 230 252 { 231 /* Create VM session: */ 232 m_session = vboxGlobal().openSession(vboxGlobal().managedVMUuid(), 233 vboxGlobal().isSeparateProcess() ? KLockType_Shared : KLockType_VM); 234 if (m_session.isNull()) 253 /* Try to create session UI: */ 254 if (!UISession::create(m_pSession, this)) 235 255 return false; 236 237 /* Create UI session: */238 m_pSession = new UISession(this, m_session);239 256 240 257 /* Preventing application from closing in case of window(s) closed: */ … … 272 289 { 273 290 /* Load 'visual state' option: */ 291 if (uisession()) 274 292 { 275 293 /* Load restricted visual states: */ … … 299 317 { 300 318 /* Save 'visual state' option: */ 319 if (uisession()) 301 320 { 302 321 /* Get requested visual state: */ … … 324 343 m_pVisualState = 0; 325 344 326 /* Delete UI session: */ 327 delete m_pSession; 328 m_pSession = 0; 329 330 /* Free session finally: */ 331 m_session.UnlockMachine(); 332 m_session.detach(); 345 /* Destroy session UI if necessary: */ 346 if (uisession()) 347 UISession::destroy(m_pSession); 333 348 334 349 /* Quit application: */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.h
r52995 r53000 27 27 /* COM includes: */ 28 28 #include "COMEnums.h" 29 #include "CSession.h"30 29 31 30 /* Forward declarations: */ … … 51 50 * @return true if machine was started, false otherwise. */ 52 51 static bool startMachine(const QString &strID); 52 /** Static constructor. */ 53 static bool create(); 53 54 /** Static destructor. */ 54 55 static void destroy(); … … 96 97 static UIMachine* m_spInstance; 97 98 98 /** Holds the session instance. */99 CSession m_session;100 101 99 /** Holds the session UI instance. */ 102 100 UISession *m_pSession; -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp
r52999 r53000 128 128 #endif /* Q_WS_MAC */ 129 129 130 UISession::UISession(UIMachine *pMachine, CSession &sessionReference) 130 /* static */ 131 bool UISession::create(UISession *&pSession, UIMachine *pMachine) 132 { 133 /* Make sure null pointer passed: */ 134 AssertReturn(pSession == 0, false); 135 136 /* Create session UI: */ 137 pSession = new UISession(pMachine); 138 /* Make sure it's prepared: */ 139 if (!pSession->prepare()) 140 { 141 /* Destroy session UI otherwise: */ 142 destroy(pSession); 143 /* False in that case: */ 144 return false; 145 } 146 /* True by default: */ 147 return true; 148 } 149 150 /* static */ 151 void UISession::destroy(UISession *&pSession) 152 { 153 /* Make sure valid pointer passed: */ 154 AssertReturnVoid(pSession != 0); 155 156 /* Cleanup session UI: */ 157 pSession->cleanup(); 158 /* Destroy session: */ 159 delete pSession; 160 pSession = 0; 161 } 162 163 UISession::UISession(UIMachine *pMachine) 131 164 : QObject(pMachine) 132 165 /* Base variables: */ 133 166 , m_pMachine(pMachine) 134 , m_session(sessionReference)135 167 , m_pActionPool(0) 136 168 #ifdef Q_WS_MAC … … 139 171 /* Common variables: */ 140 172 , m_machineStatePrevious(KMachineState_Null) 141 , m_machineState( session().GetMachine().GetState())173 , m_machineState(KMachineState_Null) 142 174 #ifndef Q_WS_MAC 143 175 , m_pMachineWindowIcon(0) … … 181 213 , m_fIsHidingHostPointer(true) 182 214 { 215 } 216 217 bool UISession::prepare() 218 { 219 /* Prepare session: */ 220 if (!prepareSession()) 221 return false; 222 183 223 /* Prepare actions: */ 184 224 prepareActions(); … … 206 246 sigaction(SIGUSR1, &sa, NULL); 207 247 #endif /* VBOX_GUI_WITH_KEYS_RESET_HANDLER */ 248 249 /* True by default: */ 250 return true; 208 251 } 209 252 210 253 UISession::~UISession() 254 { 255 } 256 257 void UISession::cleanup() 211 258 { 212 259 #ifdef Q_WS_WIN … … 230 277 /* Cleanup actions: */ 231 278 cleanupActions(); 279 280 /* Cleanup session: */ 281 cleanupSession(); 232 282 } 233 283 … … 966 1016 } 967 1017 1018 bool UISession::prepareSession() 1019 { 1020 /* Open session: */ 1021 m_session = vboxGlobal().openSession(vboxGlobal().managedVMUuid(), 1022 vboxGlobal().isSeparateProcess() 1023 ? KLockType_Shared : KLockType_VM); 1024 if (m_session.isNull()) 1025 return false; 1026 1027 /* Update machine-state: */ 1028 m_machineState = m_session.GetMachine().GetState(); 1029 1030 /* True by default: */ 1031 return true; 1032 } 1033 968 1034 void UISession::prepareConsoleEventHandlers() 969 1035 { … … 1325 1391 } 1326 1392 1393 void UISession::cleanupSession() 1394 { 1395 /* Close session: */ 1396 if (!m_session.isNull()) 1397 { 1398 m_session.UnlockMachine(); 1399 m_session.detach(); 1400 } 1401 } 1402 1327 1403 #ifdef Q_WS_MAC 1328 1404 void UISession::updateMenu() -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h
r52558 r53000 29 29 /* COM includes: */ 30 30 #include "COMEnums.h" 31 #include "CSession.h" 31 32 32 33 /* Forward declarations: */ … … 36 37 class UIMachineLogic; 37 38 class UIActionPool; 38 class CSession;39 39 class CUSBDevice; 40 40 class CNetworkAdapter; … … 77 77 public: 78 78 79 /* Machine uisession constructor/destructor: */ 80 UISession(UIMachine *pMachine, CSession &session); 81 virtual ~UISession(); 79 /** Factory constructor. */ 80 static bool create(UISession *&pSession, UIMachine *pMachine); 81 /** Factory destructor. */ 82 static void destroy(UISession *&pSession); 82 83 83 84 /* API: Runtime UI stuff: */ … … 309 310 private: 310 311 312 /** Constructor. */ 313 UISession(UIMachine *pMachine); 314 /** Destructor. */ 315 ~UISession(); 316 311 317 /* Private getters: */ 312 318 UIMachine* uimachine() const { return m_pMachine; } 313 319 314 320 /* Prepare helpers: */ 321 bool prepare(); 322 bool prepareSession(); 315 323 void prepareActions(); 316 324 void prepareConnections(); … … 327 335 void cleanupConnections(); 328 336 void cleanupActions(); 337 void cleanupSession(); 338 void cleanup(); 329 339 330 340 #ifdef Q_WS_MAC … … 344 354 /* Private variables: */ 345 355 UIMachine *m_pMachine; 346 CSession &m_session; 356 357 /** Holds the session instance. */ 358 CSession m_session; 347 359 348 360 /** Holds the action-pool instance. */
Note:
See TracChangeset
for help on using the changeset viewer.