Changeset 53047 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Oct 13, 2014 5:26:09 PM (10 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/runtime
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp
r53046 r53047 349 349 /* Discard the current state if requested: */ 350 350 if (fIncludingDiscard) 351 { 352 /* Prepare the snapshot-discard progress: */ 353 CSnapshot snapshot = machine().GetCurrentSnapshot(); 354 CProgress progress = console().RestoreSnapshot(snapshot); 355 if (!console().isOk()) 356 return msgCenter().cannotRestoreSnapshot(console(), snapshot.GetName(), machineName()); 357 358 /* Show the snapshot-discard progress: */ 359 msgCenter().showModalProgressDialog(progress, machineName(), ":/progress_snapshot_discard_90px.png"); 360 if (progress.GetResultCode() != 0) 361 return msgCenter().cannotRestoreSnapshot(progress, snapshot.GetName(), machineName()); 362 } 351 return restoreCurrentSnapshot(); 363 352 } 364 353 else … … 386 375 /* Passed: */ 387 376 return true; 377 } 378 379 bool UISession::restoreCurrentSnapshot() 380 { 381 /* Search for corresponding VM: */ 382 CVirtualBox vbox = vboxGlobal().virtualBox(); 383 const QString strMachineID = vboxGlobal().managedVMUuid(); 384 const CMachine mach = vbox.FindMachine(strMachineID); 385 if (vbox.isOk() && !mach.isNull()) 386 { 387 /* Open a direct session to modify that VM: */ 388 CSession sess = vboxGlobal().openSession(vboxGlobal().managedVMUuid(), 389 vboxGlobal().isSeparateProcess() 390 ? KLockType_Write : KLockType_Shared); 391 if (!sess.isNull()) 392 { 393 /* Acquire console for this session: */ 394 CConsole cons = sess.GetConsole(); 395 if (!cons.isNull()) 396 { 397 /* Prepare the snapshot-discard progress: */ 398 const CSnapshot snap = mach.GetCurrentSnapshot(); 399 CProgress prog = cons.RestoreSnapshot(snap); 400 if (cons.isOk()) 401 { 402 /* Show snapshot restoration progress: */ 403 msgCenter().showModalProgressDialog(prog, mach.GetName(), ":/progress_snapshot_discard_90px.png"); 404 if (prog.GetResultCode() != 0) 405 { 406 /* Unable to restore snapshot: */ 407 msgCenter().cannotRestoreSnapshot(prog, snap.GetName(), mach.GetName()); 408 } 409 } 410 else 411 { 412 /* Unable to restore snapshot: */ 413 return msgCenter().cannotRestoreSnapshot(cons, snap.GetName(), machineName()); 414 } 415 } 416 /* Unlock machine finally: */ 417 sess.UnlockMachine(); 418 } 419 else 420 { 421 /* Unable to open session to modify VM: */ 422 return false; 423 } 424 } 425 else 426 { 427 /* Unable to find VM: */ 428 msgCenter().cannotFindMachineById(vbox, strMachineID); 429 return false; 430 } 388 431 } 389 432 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h
r53046 r53047 95 95 bool shutdown(); 96 96 bool powerOff(bool fIncludingDiscard, bool &fServerCrashed); 97 bool restoreCurrentSnapshot(); 97 98 void closeRuntimeUI(); 98 99
Note:
See TracChangeset
for help on using the changeset viewer.