VirtualBox

Changeset 26898 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Feb 28, 2010 7:46:25 PM (15 years ago)
Author:
vboxsync
Message:

FE/Qt4: New running VM core: fixing few VM closure bugs.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/runtime
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp

    r26896 r26898  
    587587    m_pRunningOrPausedActions->setEnabled(uisession()->isRunning() || uisession()->isPaused());
    588588
    589     /* Do we have GURU? */
    590     bool fIsGuruMeditation = false;
    591 
    592589    switch (state)
    593590    {
    594         case KMachineState_Stuck:
    595         {
    596             /* We will process GURU later: */
    597             fIsGuruMeditation = true;
     591        case KMachineState_Stuck: // TODO: Test it!
     592        {
     593            /* Prevent machine view from resizing: */
     594            uisession()->setGuestResizeIgnored(true);
     595
     596            /* Get console: */
     597            CConsole console = session().GetConsole();
     598
     599            /* Take the screenshot for debugging purposes and save it */
     600            QString strLogFolder = console.GetMachine().GetLogFolder();
     601            QString strFileName = strLogFolder + "/VBox.png";
     602            CDisplay display = console.GetDisplay();
     603            QImage shot = QImage(display.GetWidth(), display.GetHeight(), QImage::Format_RGB32);
     604            display.TakeScreenShot(shot.bits(), shot.width(), shot.height());
     605            shot.save(QFile::encodeName(strFileName), "PNG");
     606
     607            /* Warn the user about GURU: */
     608            if (vboxProblem().remindAboutGuruMeditation(console, QDir::toNativeSeparators(strLogFolder)))
     609            {
     610                console.PowerDown();
     611                if (!console.isOk())
     612                    vboxProblem().cannotStopMachine(console);
     613            }
    598614            break;
    599615        }
     
    625641            break;
    626642        }
     643        case KMachineState_PoweredOff:
     644        case KMachineState_Saved:
     645        case KMachineState_Teleported:
     646        case KMachineState_Aborted:
     647        {
     648            /* Close VM if it was turned off and closure allowed: */
     649            if (!isPreventAutoClose())
     650            {
     651                /* VM has been powered off, saved or aborted, no matter
     652                 * internally or externally. We must *safely* close VM window(s): */
     653                QTimer::singleShot(0, uisession(), SLOT(sltCloseVirtualSession()));
     654            }
     655            break;
     656        }
    627657#ifdef Q_WS_X11
    628658        case KMachineState_Starting:
     
    639669            break;
    640670    }
    641 
    642     /* Close VM if was closed someway: */
    643     if (uisession()->isTurnedOff())
    644     {
    645         /* VM has been powered off or saved or aborted, no matter internally or externally.
    646          * We must *safely* close the console window unless auto closure is disabled: */
    647         QTimer::singleShot(0, uisession(), SLOT(sltCloseVirtualSession()));
    648         return;
    649     }
    650 
    651 #if 0 // TODO: Postprocess GURU!
    652     if (fIsGuruMeditation)
    653     {
    654         uisession()->setGuestResizeIgnored(true);
    655 
    656         CConsole console = session().GetConsole();
    657         QString strLogFolder = console.GetMachine().GetLogFolder();
    658 
    659         /* Take the screenshot for debugging purposes and save it */
    660         QString strFileName = strLogFolder + "/VBox.png";
    661         CDisplay display = console.GetDisplay();
    662         QImage shot = QImage(display.GetWidth(), display.GetHeight(), QImage::Format_RGB32);
    663         display.TakeScreenShot(shot.bits(), shot.width(), shot.height());
    664         shot.save(QFile::encodeName(strFileName), "PNG");
    665 
    666         /* Warn the user about GURU: */
    667         if (vboxProblem().remindAboutGuruMeditation(console, QDir::toNativeSeparators(strLogFolder)))
    668         {
    669             qApp->processEvents();
    670             console.PowerDown();
    671             if (!console.isOk())
    672                 vboxProblem().cannotStopMachine(console);
    673         }
    674     }
    675 #endif
    676671}
    677672
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.cpp

    r26892 r26898  
    130130void UIMachineWindow::closeEvent(QCloseEvent *pEvent)
    131131{
     132    /* Always ignore close event: */
     133    pEvent->ignore();
     134
     135    /* Should we close application? */
     136    bool fCloseApplication = false;
     137
    132138    switch (uisession()->machineState())
    133139    {
     
    139145        case KMachineState_TeleportingPausedVM: // TODO: Test this!
    140146        {
    141             /* Ignoring close event initially: */
    142             pEvent->ignore();
    143 
    144147            bool success = true;
     148
     149            /* Get the ACPI status early before pausing VM: */
     150            bool isACPIEnabled = session().GetConsole().GetGuestEnteredACPIMode();
    145151
    146152            bool fWasPaused = uisession()->isPaused() || uisession()->machineState() == KMachineState_Stuck;
     
    156162                success = false;
    157163
     164                /* Preventing closure right after we had paused: */
     165                machineLogic()->setPreventAutoClose(true);
     166
    158167                /* Get the machine: */
    159168                CMachine machine = session().GetMachine();
    160 
    161                 /* Get the ACPI status: */
    162                 bool isACPIEnabled = session().GetConsole().GetGuestEnteredACPIMode();
    163169
    164170                /* Prepare close dialog: */
     
    172178                    dlg.mCbDiscardCurState->setText(dlg.mCbDiscardCurState->text().arg(machine.GetCurrentSnapshot().GetName()));
    173179
    174                 /* Close choice string tags: */
     180                /* Choice string tags for close-dialog: */
    175181                QString strSave("save");
    176182                QString strShutdown("shutdown");
     
    284290                    }
    285291
    286                     if (success)
    287                     {
    288                         /* Accept the close action on success: */
    289                         pEvent->accept();
    290                     }
    291 
    292292                    if (success || fWasShutdown)
    293293                    {
     
    310310                        AssertWrapperOk(machine);
    311311                    }
     312
     313                    fCloseApplication = success;
    312314                }
    313315            }
    314316
    315             if (uisession()->machineState() == KMachineState_PoweredOff ||
    316                 uisession()->machineState() == KMachineState_Saved ||
    317                 uisession()->machineState() == KMachineState_Teleported ||
    318                 uisession()->machineState() == KMachineState_Aborted)
     317            if (!success)
    319318            {
    320                 /* The machine has been stopped while showing the Close or the Pause
    321                  * failure dialog - accept the close event immediately: */
    322                 pEvent->accept();
    323             }
    324             else
    325             {
    326                 if (!success)
    327                 {
    328                     /* Restore the running state if needed: */
    329                     if (!fWasPaused && uisession()->machineState() == KMachineState_Paused)
    330                         uisession()->unpause();
    331                 }
     319                /* Restore the running state if needed: */
     320                if (!fWasPaused && uisession()->machineState() == KMachineState_Paused)
     321                    uisession()->unpause();
    332322            }
    333323            break;
    334324        }
    335325
    336 #if 0 // TODO: Check if all those states processing is really needed:
    337         case KMachineState_PoweredOff:
    338         case KMachineState_Saved:
    339         case KMachineState_Teleported:
    340         case KMachineState_Aborted:
    341         {
    342             /* The machine has been already powered off or saved or aborted - close the window immediately: */
    343             pEvent->accept();
     326        default:
    344327            break;
    345         }
    346 #endif
    347 
    348         default:
    349         {
    350             /* The machine is in some temporary state like Saving or Stopping.
    351              * Ignore the close event. It will be processed later if something will be failed: */
    352             pEvent->ignore();
    353             break;
    354         }
    355328    }
    356329
    357     /* Postprocess event if accepted: */
    358     if (pEvent->isAccepted())
     330    /* Allowing closure: */
     331    machineLogic()->setPreventAutoClose(false);
     332
     333    if (fCloseApplication)
    359334    {
    360 #ifndef VBOX_GUI_SEPARATE_VM_PROCESS
    361         vboxGlobal().selectorWnd().show();
    362 #endif
    363 
    364 #ifdef VBOX_WITH_DEBUGGER_GUI
    365         /* Close & destroy the debugger GUI */
    366         // TODO: Check that logic!
    367         //dbgDestroy();
    368 #endif
    369 
    370         /* Notify all the top-level child dialogs about closing: */
    371         // TODO: Notify about closing!
    372         //emit closing();
    373 
    374         /* Reject that event finally as uimachine will close window iteself: */
    375         pEvent->ignore();
    376 
    377         /* Request uisession closing: */
     335        /* VM has been powered off or saved. We must *safely* close the VM window(s): */
    378336        QTimer::singleShot(0, uisession(), SLOT(sltCloseVirtualSession()));
    379337    }
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette