Changeset 52977 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Oct 7, 2014 5:46:32 PM (10 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp
r52957 r52977 372 372 373 373 return *mSelectorWnd; 374 }375 376 bool VBoxGlobal::startMachine(const QString &strMachineId)377 {378 /* Some restrictions: */379 AssertMsg(mValid, ("VBoxGlobal is invalid"));380 AssertMsg(!m_pVirtualMachine, ("Machine already started"));381 382 /* Restore current snapshot if asked to do so: */383 if (mRestoreCurrentSnapshot)384 {385 CSession session = vboxGlobal().openSession(strMachineId, KLockType_VM);386 if (session.isNull())387 return false;388 389 CConsole console = session.GetConsole();390 CMachine machine = session.GetMachine();391 CSnapshot snapshot = machine.GetCurrentSnapshot();392 CProgress progress = console.RestoreSnapshot(snapshot);393 if (!console.isOk())394 return msgCenter().cannotRestoreSnapshot(console, snapshot.GetName(), machine.GetName());395 396 /* Show the snapshot-discard progress: */397 msgCenter().showModalProgressDialog(progress, machine.GetName(), ":/progress_snapshot_discard_90px.png");398 if (progress.GetResultCode() != 0)399 return msgCenter().cannotRestoreSnapshot(progress, snapshot.GetName(), machine.GetName());400 session.UnlockMachine();401 402 /* Clear the restore flag so media enum can be started, should be safe now. */403 mRestoreCurrentSnapshot = false;404 }405 406 /* Start virtual machine: */407 return UIMachine::create(&m_pVirtualMachine);408 }409 410 UIMachine* VBoxGlobal::virtualMachine()411 {412 return m_pVirtualMachine;413 374 } 414 375 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h
r52902 r52977 110 110 UISelectorWindow &selectorWnd(); 111 111 112 /* VM stuff: */ 113 bool startMachine(const QString &strMachineId); 114 UIMachine* virtualMachine(); 112 /** Returns current virtual machine. */ 113 UIMachine* virtualMachine() const { return m_pVirtualMachine; } 114 /** Defines current virtual @a pMachine. */ 115 void setVirtualMachine(UIMachine *pMachine) { m_pVirtualMachine = pMachine; } 116 115 117 QWidget* activeMachineWindow(); 116 118 … … 140 142 bool isKWinManaged() const { return mIsKWinManaged; } 141 143 144 /** Returns whether we should restore current snapshot before VM started. */ 142 145 bool shouldRestoreCurrentSnapshot() const { return mRestoreCurrentSnapshot; } 146 /** Defines whether we should fRestore current snapshot before VM started. */ 147 void setShouldRestoreCurrentSnapshot(bool fRestore) { mRestoreCurrentSnapshot = fRestore; } 148 143 149 bool isPatmDisabled() const { return mDisablePatm; } 144 150 bool isCsamDisabled() const { return mDisableCsam; } -
trunk/src/VBox/Frontends/VirtualBox/src/main.cpp
r52902 r52977 26 26 # include "UIMessageCenter.h" 27 27 # include "UISelectorWindow.h" 28 # include "UIMachine.h" 28 29 # include "VBoxUtils.h" 29 30 # include "UIModalWindowManager.h" … … 456 457 { 457 458 /* Make sure VM is started: */ 458 if (! vboxGlobal().startMachine(vboxGlobal().managedVMUuid()))459 if (!UIMachine::startMachine(vboxGlobal().managedVMUuid())) 459 460 break; 460 461 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.cpp
r52902 r52977 30 30 # include "UIMessageCenter.h" 31 31 32 /* COM includes: */ 33 # include "CMachine.h" 34 # include "CConsole.h" 35 # include "CSnapshot.h" 36 # include "CProgress.h" 37 32 38 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ 33 39 … … 91 97 92 98 /* static */ 93 bool UIMachine::create(UIMachine **ppSelf) 94 { 95 UIMachine *pMachine = new UIMachine(ppSelf); 96 if (!pMachine) 97 return false; 99 bool UIMachine::startMachine(const QString &strID) 100 { 101 /* Some restrictions: */ 102 AssertMsgReturn(vboxGlobal().isValid(), ("VBoxGlobal is invalid.."), false); 103 AssertMsgReturn(!vboxGlobal().virtualMachine(), ("Machine already started.."), false); 104 105 /* Restore current snapshot if requested: */ 106 if (vboxGlobal().shouldRestoreCurrentSnapshot()) 107 { 108 /* Create temporary session: */ 109 CSession session = vboxGlobal().openSession(strID, KLockType_VM); 110 if (session.isNull()) 111 return false; 112 113 /* Which VM we operate on? */ 114 CMachine machine = session.GetMachine(); 115 /* Which snapshot we are restoring? */ 116 CSnapshot snapshot = machine.GetCurrentSnapshot(); 117 118 /* Open corresponding console: */ 119 CConsole console = session.GetConsole(); 120 /* Prepare restore-snapshot progress: */ 121 CProgress progress = console.RestoreSnapshot(snapshot); 122 if (!console.isOk()) 123 return msgCenter().cannotRestoreSnapshot(console, snapshot.GetName(), machine.GetName()); 124 125 /* Show the snapshot-discarding progress: */ 126 msgCenter().showModalProgressDialog(progress, machine.GetName(), ":/progress_snapshot_discard_90px.png"); 127 if (progress.GetResultCode() != 0) 128 return msgCenter().cannotRestoreSnapshot(progress, snapshot.GetName(), machine.GetName()); 129 130 /* Unlock session finally: */ 131 session.UnlockMachine(); 132 133 /* Clear snapshot-restoring request: */ 134 vboxGlobal().setShouldRestoreCurrentSnapshot(false); 135 } 136 137 /* Create machine UI: */ 138 UIMachine *pMachine = new UIMachine; 139 140 /* Prepare machine UI: */ 98 141 return pMachine->prepare(); 99 142 } 100 143 101 UIMachine::UIMachine( UIMachine **ppSelf)144 UIMachine::UIMachine() 102 145 : QObject(0) 103 , m_ppThis(ppSelf)104 146 , initialStateType(UIVisualStateType_Normal) 105 147 , m_pSession(0) … … 107 149 , m_allowedVisualStates(UIVisualStateType_Invalid) 108 150 { 109 /* Store self pointer: */ 110 if (m_ppThis) 111 *m_ppThis = this; 151 /* Make sure VBoxGlobal is aware of VM creation: */ 152 vboxGlobal().setVirtualMachine(this); 112 153 } 113 154 … … 192 233 m_session.detach(); 193 234 194 /* Clear self pointer: */195 *m_ppThis = 0;235 /* Make sure VBoxGlobal is aware of VM destruction: */ 236 vboxGlobal().setVirtualMachine(0); 196 237 197 238 /* Quit application: */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.h
r52894 r52977 46 46 public: 47 47 48 static bool create(UIMachine **ppSelf); 48 /** Static factory to start machine with passed @a strID. 49 * @return true if machine was started, false otherwise. */ 50 static bool startMachine(const QString &strID); 49 51 50 /* Virtual Machine constructor/destructor: */ 51 UIMachine(UIMachine **ppSelf); 52 /** Constructor. */ 53 UIMachine(); 54 /** Destructor. */ 52 55 virtual ~UIMachine(); 53 56 … … 84 87 85 88 /* Private variables: */ 86 UIMachine **m_ppThis;87 89 UIVisualStateType initialStateType; 88 90 CSession m_session;
Note:
See TracChangeset
for help on using the changeset viewer.