Changeset 53049 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Oct 13, 2014 6:02:36 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp
r53047 r53049 379 379 bool UISession::restoreCurrentSnapshot() 380 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 { 381 /* Prepare result: */ 382 bool fResult = false; 383 384 /* Simulate try-catch block: */ 385 do 386 { 387 /* Search for corresponding VM: */ 388 CVirtualBox vbox = vboxGlobal().virtualBox(); 389 const QString strMachineID = vboxGlobal().managedVMUuid(); 390 const CMachine mach = vbox.FindMachine(strMachineID); 391 if (!vbox.isOk() || mach.isNull()) 392 { 393 /* Unable to find VM: */ 394 msgCenter().cannotFindMachineById(vbox, strMachineID); 395 break; 396 } 397 387 398 /* Open a direct session to modify that VM: */ 388 399 CSession sess = vboxGlobal().openSession(vboxGlobal().managedVMUuid(), 389 400 vboxGlobal().isSeparateProcess() 390 401 ? KLockType_Write : KLockType_Shared); 391 if (!sess.isNull()) 402 if (sess.isNull()) 403 { 404 /* Unable to open session: */ 405 break; 406 } 407 408 /* Simulate try-catch block: */ 409 do 392 410 { 393 411 /* Acquire console for this session: */ 394 412 CConsole cons = sess.GetConsole(); 395 if ( !cons.isNull())413 if (cons.isNull()) 396 414 { 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 /* Unable to acquire console: */ 416 break; 415 417 } 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 } 418 419 /* Prepare the snapshot-discard progress: */ 420 const CSnapshot snap = mach.GetCurrentSnapshot(); 421 CProgress prog = cons.RestoreSnapshot(snap); 422 if (!cons.isOk() || prog.isNull()) 423 { 424 /* Unable to restore snapshot: */ 425 msgCenter().cannotRestoreSnapshot(cons, snap.GetName(), machineName()); 426 break; 427 } 428 429 /* Show the snapshot-discard progress: */ 430 msgCenter().showModalProgressDialog(prog, mach.GetName(), ":/progress_snapshot_discard_90px.png"); 431 if (prog.GetResultCode() != 0) 432 { 433 /* Unable to restore snapshot: */ 434 msgCenter().cannotRestoreSnapshot(prog, snap.GetName(), mach.GetName()); 435 break; 436 } 437 438 /* Success: */ 439 fResult = true; 440 } 441 while (0); 442 443 /* Unlock machine finally: */ 444 sess.UnlockMachine(); 445 } 446 while (0); 447 448 /* Return result: */ 449 return fResult; 431 450 } 432 451
Note:
See TracChangeset
for help on using the changeset viewer.