VirtualBox

Changeset 3288 in vbox for trunk/src


Ignore:
Timestamp:
Jun 26, 2007 12:19:05 PM (18 years ago)
Author:
vboxsync
Message:

Main: More precise check of whether the VM is running or not when USB attach/detach notifications arrive.

Location:
trunk/src/VBox/Main
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/ConsoleImpl.cpp

    r3278 r3288  
    31153115    AutoLock alock (this);
    31163116
    3117     /* VM might have been stopped when this message arrives */
    3118     if (mMachineState < MachineState_Running ||
    3119         mMachineState == MachineState_Stopping)
    3120     {
     3117    /* protect mpVM (we don't need error info, since it's a callback) */
     3118    AutoVMCallerQuiet autoVMCaller (this);
     3119    if (FAILED (autoVMCaller.rc()))
     3120    {
     3121        /* The VM may be no more operational when this message arrives
     3122         * (e.g. it may be Saving or Stopping or just PoweredOff) --
     3123         * autoVMCaller.rc() will return a failure in this case. */
    31213124        LogFlowThisFunc (("Attach request ignored (mMachineState=%d).\n",
    31223125                          mMachineState));
    3123         return E_FAIL;
     3126        return autoVMCaller.rc();
    31243127    }
    31253128
     
    31303133        return S_OK;
    31313134    }
    3132 
    3133     /* protect mpVM */
    3134     AutoVMCaller autoVMCaller (this);
    3135     CheckComRCReturnRC (autoVMCaller.rc());
    31363135
    31373136    /* Don't proceed unless we've found the usb controller. */
     
    31983197    }
    31993198
    3200     /* VM might have been stopped when this message arrives */
     3199
    32013200    if (device.isNull())
    32023201    {
    3203         LogFlowThisFunc (("Device not found.\n"));
    3204         if (mMachineState < MachineState_Running ||
    3205             mMachineState == MachineState_Stopping)
     3202        LogFlowThisFunc (("USB device not found.\n"));
     3203
     3204        /* The VM may be no more operational when this message arrives
     3205         * (e.g. it may be Saving or Stopping or just PoweredOff). Use
     3206         * AutoVMCaller to detect it -- AutoVMCaller::rc() will return a
     3207         * failure in this case. */
     3208
     3209        AutoVMCallerQuiet autoVMCaller (this);
     3210        if (FAILED (autoVMCaller.rc()))
    32063211        {
    32073212            LogFlowThisFunc (("Detach request ignored (mMachineState=%d).\n",
    32083213                              mMachineState));
    3209             return E_FAIL;
    3210         }
    3211         /* the device must be in the list */
     3214            return autoVMCaller.rc();
     3215        }
     3216
     3217        /* the device must be in the list otherwise */
    32123218        AssertFailedReturn (E_FAIL);
    32133219    }
  • trunk/src/VBox/Main/include/ConsoleImpl.h

    r3278 r3288  
    272272
    273273    /**
     274     *  Same as AutoVMCaller but doesn't set extended error info on failure.
     275     */
     276    typedef AutoVMCallerBase <true, false> AutoVMCallerQuiet;
     277
     278    /**
    274279     *  Base template for SaveVMPtr and SaveVMPtrQuiet.
    275280     */
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