VirtualBox

Ignore:
Timestamp:
Mar 11, 2010 2:01:19 AM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
58658
Message:

FE/Qt4: New running VM core: unifying some code common for all modes logics.

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

Legend:

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

    r27224 r27263  
    471471    }
    472472#endif /* Q_WS_MAC */
     473}
     474
     475void UIMachineLogic::tryToStartMachine()
     476{
     477    /* If we are started already => just return: */
     478    if (uisession()->isRunning() || uisession()->isPaused())
     479        return;
     480
     481    /* Prepare console powerup: */
     482    prepareConsolePowerUp();
     483
     484    /* Get current machine/console: */
     485    CMachine machine = session().GetMachine();
     486    CConsole console = session().GetConsole();
     487
     488    /* Start VM: */
     489    CProgress progress = vboxGlobal().isStartPausedEnabled() || vboxGlobal().isDebuggerAutoShowEnabled() ?
     490                         console.PowerUpPaused() : console.PowerUp();
     491
     492#if 0 // TODO: Check immediate failure!
     493    /* Check for an immediate failure: */
     494    if (!console.isOk())
     495    {
     496        vboxProblem().cannotStartMachine(console);
     497        machineWindowWrapper()->machineWindow()->close();
     498        return;
     499    }
     500
     501    /* Disable auto-closure because we want to have a chance to show the error dialog on startup failure: */
     502    setPreventAutoClose(true);
     503#endif
     504
     505    /* Show "Starting/Restoring" progress dialog: */
     506    if (uisession()->isSaved())
     507        vboxProblem().showModalProgressDialog(progress, machine.GetName(), defaultMachineWindow()->machineWindow(), 0);
     508    else
     509        vboxProblem().showModalProgressDialog(progress, machine.GetName(), defaultMachineWindow()->machineWindow());
     510
     511#if 0 // TODO: Check immediate failure!
     512    /* Check for an progress failure */
     513    if (progress.GetResultCode() != 0)
     514    {
     515        vboxProblem().cannotStartMachine(progress);
     516        machineWindowWrapper()->machineWindow()->close();
     517        return;
     518    }
     519
     520    /* Enable auto-closure again: */
     521    setPreventAutoClose(false);
     522
     523    /* Check if we missed a really quick termination after successful startup, and process it if we did: */
     524    if (uisession()->isTurnedOff())
     525    {
     526        machineWindowWrapper()->machineWindow()->close();
     527        return;
     528    }
     529#endif
     530
     531#if 0 // TODO: Rework debugger logic!
     532# ifdef VBOX_WITH_DEBUGGER_GUI
     533    /* Open the debugger in "full screen" mode requested by the user. */
     534    else if (vboxGlobal().isDebuggerAutoShowEnabled())
     535    {
     536        /* console in upper left corner of the desktop. */
     537        QRect rct (0, 0, 0, 0);
     538        QDesktopWidget *desktop = QApplication::desktop();
     539        if (desktop)
     540            rct = desktop->availableGeometry(pos());
     541        move (QPoint (rct.x(), rct.y()));
     542
     543        if (vboxGlobal().isDebuggerAutoShowStatisticsEnabled())
     544            sltShowDebugStatistics();
     545        if (vboxGlobal().isDebuggerAutoShowCommandLineEnabled())
     546            sltShowDebugCommandLine();
     547
     548        if (!vboxGlobal().isStartPausedEnabled())
     549            machineWindowWrapper()->machineView()->pause (false);
     550    }
     551# endif
     552#endif
     553
     554#ifdef VBOX_WITH_UPDATE_REQUEST
     555    /* Check for updates if necessary: */
     556    vboxGlobal().showUpdateDialog(false /* force request? */);
     557#endif
     558
     559    /* Warn listeners about machine was started: */
     560    emit sigMachineStarted();
    473561}
    474562
     
    856944    /* Variable falgs: */
    857945    bool fIsAdditionsActive = uisession()->isGuestAdditionsActive();
    858     bool fIsSupportsGraphics = fIsAdditionsActive && uisession()->isGuestSupportsGraphics();
    859     bool fIsSupportsSeamless = fIsSupportsGraphics && uisession()->isGuestSupportsSeamless();
     946    bool fIsSupportsGraphics = uisession()->isGuestSupportsGraphics();
     947    bool fIsSupportsSeamless = uisession()->isGuestSupportsSeamless();
    860948
    861949    /* Update action states: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.h

    r27215 r27263  
    8383#endif /* Q_WS_MAC */
    8484
     85signals:
     86
     87    void sigMachineStarted();
     88
    8589protected:
    8690
     
    102106    void addMachineWindow(UIMachineWindow *pMachineWindow);
    103107    void retranslateUi();
     108    void tryToStartMachine();
    104109#ifdef Q_WS_MAC
    105110    bool isDockIconPreviewEnabled() const { return m_fIsDockIconEnabled; }
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineLogicFullscreen.cpp

    r27234 r27263  
    182182void UIMachineLogicFullscreen::prepareMachineWindows()
    183183{
    184     /* Get monitor count: */
    185     ulong uMonitorCount = session().GetMachine().GetMonitorCount();
    186 
    187     /* Do not create window(s) if created already: */
    188     if ((ulong)machineWindows().size() == uMonitorCount)
     184    /* Do not create window(s) if they created already: */
     185    if (isMachineWindowsCreated())
    189186        return;
    190187
    191     /* List should not be filled partially: */
    192     AssertMsg(machineWindows().size() == 0, ("Windows list is filled partially, something broken!\n"));
    193 
    194 #ifdef Q_WS_MAC
     188#ifdef Q_WS_MAC // TODO: Is that "darwinSetFrontMostProcess" really need here?
    195189    /* We have to make sure that we are getting the front most process.
    196190     * This is necessary for Qt versions > 4.3.3: */
     
    200194
    201195#if 0 // TODO: Add seamless multi-monitor support!
     196    /* Get monitors count: */
     197    ulong uMonitorCount = session().GetMachine().GetMonitorCount();
    202198    /* Create machine window(s): */
    203199    for (ulong uScreenId = 0; uScreenId < uMonitorCount; ++ uScreenId)
     
    211207#endif
    212208
    213     /* Notify others about machine window(s) created: */
     209    /* Remember what machine window(s) created: */
    214210    setMachineWindowsCreated(true);
    215211
    216     /* If we are not started yet: */
    217     if (!uisession()->isRunning() && !uisession()->isPaused())
    218     {
    219         prepareConsolePowerUp();
    220 
    221         /* Get current machine/console: */
    222         CMachine machine = session().GetMachine();
    223         CConsole console = session().GetConsole();
    224 
    225         /* Start VM: */
    226         CProgress progress = vboxGlobal().isStartPausedEnabled() || vboxGlobal().isDebuggerAutoShowEnabled() ?
    227                              console.PowerUpPaused() : console.PowerUp();
    228 
    229 #if 0 // TODO: Check immediate failure!
    230         /* Check for an immediate failure: */
    231         if (!console.isOk())
    232         {
    233             vboxProblem().cannotStartMachine(console);
    234             machineWindowWrapper()->machineWindow()->close();
    235             return;
    236         }
    237 
    238         /* Disable auto-closure because we want to have a chance to show the error dialog on startup failure: */
    239         setPreventAutoClose(true);
    240 #endif
    241 
    242         /* Show "Starting/Restoring" progress dialog: */
    243         if (uisession()->isSaved())
    244             vboxProblem().showModalProgressDialog(progress, machine.GetName(), defaultMachineWindow()->machineWindow(), 0);
    245         else
    246             vboxProblem().showModalProgressDialog(progress, machine.GetName(), defaultMachineWindow()->machineWindow());
    247 
    248 #if 0 // TODO: Check immediate failure!
    249         /* Check for an progress failure */
    250         if (progress.GetResultCode() != 0)
    251         {
    252             vboxProblem().cannotStartMachine(progress);
    253             machineWindowWrapper()->machineWindow()->close();
    254             return;
    255         }
    256 
    257         /* Enable auto-closure again: */
    258         setPreventAutoClose(false);
    259 
    260         /* Check if we missed a really quick termination after successful startup, and process it if we did: */
    261         if (uisession()->isTurnedOff())
    262         {
    263             machineWindowWrapper()->machineWindow()->close();
    264             return;
    265         }
    266 #endif
    267 
    268 #if 0 // TODO: Rework debugger logic!
    269 # ifdef VBOX_WITH_DEBUGGER_GUI
    270         /* Open the debugger in "full screen" mode requested by the user. */
    271         else if (vboxGlobal().isDebuggerAutoShowEnabled())
    272         {
    273             /* console in upper left corner of the desktop. */
    274             QRect rct (0, 0, 0, 0);
    275             QDesktopWidget *desktop = QApplication::desktop();
    276             if (desktop)
    277                 rct = desktop->availableGeometry(pos());
    278             move (QPoint (rct.x(), rct.y()));
    279 
    280             if (vboxGlobal().isDebuggerAutoShowStatisticsEnabled())
    281                 sltShowDebugStatistics();
    282             if (vboxGlobal().isDebuggerAutoShowCommandLineEnabled())
    283                 sltShowDebugCommandLine();
    284 
    285             if (!vboxGlobal().isStartPausedEnabled())
    286                 machineWindowWrapper()->machineView()->pause (false);
    287         }
    288 # endif
    289 #endif
    290 
    291 #ifdef VBOX_WITH_UPDATE_REQUEST
    292         /* Check for updates if necessary: */
    293         vboxGlobal().showUpdateDialog(false /* force request? */);
    294 #endif
    295     }
     212    /* Check if we need to start VM: */
     213    tryToStartMachine();
    296214}
    297215
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineLogicNormal.cpp

    r27234 r27263  
    124124void UIMachineLogicNormal::prepareMachineWindows()
    125125{
    126     /* Get monitor count: */
    127     ulong uMonitorCount = session().GetMachine().GetMonitorCount();
    128 
    129     /* Do not create window(s) if created already: */
    130     if ((ulong)machineWindows().size() == uMonitorCount)
     126    /* Do not create window(s) if they created already: */
     127    if (isMachineWindowsCreated())
    131128        return;
    132129
    133     /* List should not be filled partially: */
    134     AssertMsg(machineWindows().size() == 0, ("Windows list is filled partially, something broken!\n"));
    135 
    136 #ifdef Q_WS_MAC
     130#ifdef Q_WS_MAC // TODO: Is that really need here?
    137131    /* We have to make sure that we are getting the front most process.
    138132     * This is necessary for Qt versions > 4.3.3: */
     
    140134#endif /* Q_WS_MAC */
    141135
     136    /* Get monitors count: */
     137    ulong uMonitorCount = session().GetMachine().GetMonitorCount();
    142138    /* Create machine window(s): */
    143139    for (ulong uScreenId = 0; uScreenId < uMonitorCount; ++ uScreenId)
     
    147143        machineWindows()[uScreenId - 1]->machineWindow()->raise();
    148144
    149     /* Notify others about machine window(s) created: */
     145    /* Remember what machine window(s) created: */
    150146    setMachineWindowsCreated(true);
    151147
    152     /* If we are not started yet: */
    153     if (!uisession()->isRunning() && !uisession()->isPaused())
    154     {
    155         prepareConsolePowerUp();
    156 
    157         /* Get current machine/console: */
    158         CMachine machine = session().GetMachine();
    159         CConsole console = session().GetConsole();
    160 
    161         /* Start VM: */
    162         CProgress progress = vboxGlobal().isStartPausedEnabled() || vboxGlobal().isDebuggerAutoShowEnabled() ?
    163                              console.PowerUpPaused() : console.PowerUp();
    164 
    165 #if 0 // TODO: Check immediate failure!
    166         /* Check for an immediate failure: */
    167         if (!console.isOk())
    168         {
    169             vboxProblem().cannotStartMachine(console);
    170             machineWindowWrapper()->machineWindow()->close();
    171             return;
    172         }
    173 
    174         /* Disable auto-closure because we want to have a chance to show the error dialog on startup failure: */
    175         setPreventAutoClose(true);
    176 #endif
    177 
    178         /* Show "Starting/Restoring" progress dialog: */
    179         if (uisession()->isSaved())
    180             vboxProblem().showModalProgressDialog(progress, machine.GetName(), defaultMachineWindow()->machineWindow(), 0);
    181         else
    182             vboxProblem().showModalProgressDialog(progress, machine.GetName(), defaultMachineWindow()->machineWindow());
    183 
    184 #if 0 // TODO: Check immediate failure!
    185         /* Check for an progress failure */
    186         if (progress.GetResultCode() != 0)
    187         {
    188             vboxProblem().cannotStartMachine(progress);
    189             machineWindowWrapper()->machineWindow()->close();
    190             return;
    191         }
    192 
    193         /* Enable auto-closure again: */
    194         setPreventAutoClose(false);
    195 
    196         /* Check if we missed a really quick termination after successful startup, and process it if we did: */
    197         if (uisession()->isTurnedOff())
    198         {
    199             machineWindowWrapper()->machineWindow()->close();
    200             return;
    201         }
    202 #endif
    203 
    204 #if 0 // TODO: Rework debugger logic!
    205 # ifdef VBOX_WITH_DEBUGGER_GUI
    206         /* Open the debugger in "full screen" mode requested by the user. */
    207         else if (vboxGlobal().isDebuggerAutoShowEnabled())
    208         {
    209             /* console in upper left corner of the desktop. */
    210             QRect rct (0, 0, 0, 0);
    211             QDesktopWidget *desktop = QApplication::desktop();
    212             if (desktop)
    213                 rct = desktop->availableGeometry(pos());
    214             move (QPoint (rct.x(), rct.y()));
    215 
    216             if (vboxGlobal().isDebuggerAutoShowStatisticsEnabled())
    217                 sltShowDebugStatistics();
    218             if (vboxGlobal().isDebuggerAutoShowCommandLineEnabled())
    219                 sltShowDebugCommandLine();
    220 
    221             if (!vboxGlobal().isStartPausedEnabled())
    222                 machineWindowWrapper()->machineView()->pause (false);
    223         }
    224 # endif
    225 #endif
    226 
    227 #ifdef VBOX_WITH_UPDATE_REQUEST
    228         /* Check for updates if necessary: */
    229         vboxGlobal().showUpdateDialog(false /* force request? */);
    230 #endif
    231     }
     148    /* Check if we need to start VM: */
     149    tryToStartMachine();
    232150}
    233151
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineLogicSeamless.cpp

    r27234 r27263  
    169169void UIMachineLogicSeamless::prepareMachineWindows()
    170170{
    171     /* Get monitor count: */
    172     ulong uMonitorCount = session().GetMachine().GetMonitorCount();
    173 
    174     /* Do not create window(s) if created already: */
    175     if ((ulong)machineWindows().size() == uMonitorCount)
     171    /* Do not create window(s) if they created already: */
     172    if (isMachineWindowsCreated())
    176173        return;
    177174
    178     /* List should not be filled partially: */
    179     AssertMsg(machineWindows().size() == 0, ("Windows list is filled partially, something broken!\n"));
    180 
    181 #ifdef Q_WS_MAC
     175#ifdef Q_WS_MAC // TODO: Is that really need here?
    182176    /* We have to make sure that we are getting the front most process.
    183177     * This is necessary for Qt versions > 4.3.3: */
     
    186180
    187181#if 0 // TODO: Add seamless multi-monitor support!
     182    /* Get monitors count: */
     183    ulong uMonitorCount = session().GetMachine().GetMonitorCount();
    188184    /* Create machine window(s): */
    189185    for (ulong uScreenId = 0; uScreenId < uMonitorCount; ++ uScreenId)
     
    197193#endif
    198194
    199     /* Notify others about machine window(s) created: */
     195    /* Remember what machine window(s) created: */
    200196    setMachineWindowsCreated(true);
    201197
    202     /* If we are not started yet: */
    203     if (!uisession()->isRunning() && !uisession()->isPaused())
    204     {
    205         /* Prepare console powerup: */
    206         prepareConsolePowerUp();
    207 
    208         /* Get current machine/console: */
    209         CMachine machine = session().GetMachine();
    210         CConsole console = session().GetConsole();
    211 
    212         /* Start VM: */
    213         CProgress progress = vboxGlobal().isStartPausedEnabled() || vboxGlobal().isDebuggerAutoShowEnabled() ?
    214                              console.PowerUpPaused() : console.PowerUp();
    215 
    216 #if 0 // TODO: Check immediate failure!
    217         /* Check for an immediate failure: */
    218         if (!console.isOk())
    219         {
    220             vboxProblem().cannotStartMachine(console);
    221             machineWindowWrapper()->machineWindow()->close();
    222             return;
    223         }
    224 
    225         /* Disable auto-closure because we want to have a chance to show the error dialog on startup failure: */
    226         setPreventAutoClose(true);
    227 #endif
    228 
    229         /* Show "Starting/Restoring" progress dialog: */
    230         if (uisession()->isSaved())
    231             vboxProblem().showModalProgressDialog(progress, machine.GetName(), defaultMachineWindow()->machineWindow(), 0);
    232         else
    233             vboxProblem().showModalProgressDialog(progress, machine.GetName(), defaultMachineWindow()->machineWindow());
    234 
    235 #if 0 // TODO: Check immediate failure!
    236         /* Check for an progress failure */
    237         if (progress.GetResultCode() != 0)
    238         {
    239             vboxProblem().cannotStartMachine(progress);
    240             machineWindowWrapper()->machineWindow()->close();
    241             return;
    242         }
    243 
    244         /* Enable auto-closure again: */
    245         setPreventAutoClose(false);
    246 
    247         /* Check if we missed a really quick termination after successful startup, and process it if we did: */
    248         if (uisession()->isTurnedOff())
    249         {
    250             machineWindowWrapper()->machineWindow()->close();
    251             return;
    252         }
    253 #endif
    254 
    255 #if 0 // TODO: Rework debugger logic!
    256 # ifdef VBOX_WITH_DEBUGGER_GUI
    257         /* Open the debugger in "full screen" mode requested by the user. */
    258         else if (vboxGlobal().isDebuggerAutoShowEnabled())
    259         {
    260             /* console in upper left corner of the desktop. */
    261             QRect rct (0, 0, 0, 0);
    262             QDesktopWidget *desktop = QApplication::desktop();
    263             if (desktop)
    264                 rct = desktop->availableGeometry(pos());
    265             move (QPoint (rct.x(), rct.y()));
    266 
    267             if (vboxGlobal().isDebuggerAutoShowStatisticsEnabled())
    268                 sltShowDebugStatistics();
    269             if (vboxGlobal().isDebuggerAutoShowCommandLineEnabled())
    270                 sltShowDebugCommandLine();
    271 
    272             if (!vboxGlobal().isStartPausedEnabled())
    273                 machineWindowWrapper()->machineView()->pause (false);
    274         }
    275 # endif
    276 #endif
    277 
    278 #ifdef VBOX_WITH_UPDATE_REQUEST
    279         /* Check for updates if necessary: */
    280         vboxGlobal().showUpdateDialog(false /* force request? */);
    281 #endif
    282     }
     198    /* Check if we need to start VM: */
     199    tryToStartMachine();
    283200}
    284201
Note: See TracChangeset for help on using the changeset viewer.

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