VirtualBox

Changeset 44402 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
Jan 27, 2013 11:17:46 PM (12 years ago)
Author:
vboxsync
Message:

ConsoleImpl.h/.cpp: changed SafeVMPtrBase to not mess around with pVM, only pUVM.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/ConsoleImpl.h

    r44393 r44402  
    387387        typedef AutoVMCallerBase<taQuiet, true> Base;
    388388    public:
    389         SafeVMPtrBase(Console *aThat) : Base(aThat), mpVM(NULL), mpUVM(NULL)
     389        SafeVMPtrBase(Console *aThat) : Base(aThat), mpUVM(NULL)
    390390        {
    391391            if (SUCCEEDED(Base::mRC))
    392                 Base::mRC = aThat->safeVMPtrRetainer(&mpVM, &mpUVM, taQuiet);
     392                Base::mRC = aThat->safeVMPtrRetainer(&mpUVM, taQuiet);
    393393        }
    394394        ~SafeVMPtrBase()
     
    397397                release();
    398398        }
    399 #if 1 /* to be removed... */
    400         /** Smart SaveVMPtr to PVM cast operator */
    401         operator PVM() const { return mpVM; }
    402 #endif
    403         /** Direct PVM access for printf()-like functions */
    404         PVM raw() const { return mpVM; }
    405         /** Direct PUVM access for printf()-like functions */
     399        /** Direct PUVM access. */
    406400        PUVM rawUVM() const { return mpUVM; }
    407401        /** Release the handles. */
     
    409403        {
    410404            AssertReturnVoid(SUCCEEDED(Base::mRC));
    411             Base::mThat->safeVMPtrReleaser(&mpVM, &mpUVM);
     405            Base::mThat->safeVMPtrReleaser(&mpUVM);
    412406            Base::releaseCaller();
    413407        }
    414408
    415409    private:
    416         PVM     mpVM;
    417410        PUVM    mpUVM;
    418411        DECLARE_CLS_COPY_CTOR_ASSIGN_NOOP(SafeVMPtrBase)
     
    422415
    423416    /**
    424      *  Helper class that safely manages the Console::mpVM pointer
     417     *  Helper class that safely manages the Console::mpUVM pointer
    425418     *  by calling addVMCaller() on construction and releaseVMCaller() on
    426419     *  destruction. Intended for Console children. The usage pattern is:
     
    494487    HRESULT addVMCaller(bool aQuiet = false, bool aAllowNullVM = false);
    495488    void    releaseVMCaller();
    496     HRESULT safeVMPtrRetainer(PVM *a_ppVM, PUVM *a_ppUVM, bool aQuiet);
    497     void    safeVMPtrReleaser(PVM *a_ppVM, PUVM *a_ppUVM);
     489    HRESULT safeVMPtrRetainer(PUVM *a_ppUVM, bool aQuiet);
     490    void    safeVMPtrReleaser(PUVM *a_ppUVM);
    498491
    499492    HRESULT consoleInitReleaseLog(const ComPtr<IMachine> aMachine);
     
    744737    /** The user mode VM handle. */
    745738    PUVM mpUVM;
    746     /** Holds the number of "readonly" mpVM callers (users) */
     739    /** Holds the number of "readonly" mpVM/mpUVM callers (users) */
    747740    uint32_t mVMCallers;
    748741    /** Semaphore posted when the number of mpVM callers drops to zero */
  • trunk/src/VBox/Main/src-client/ConsoleImpl.cpp

    r44393 r44402  
    156156          mProgress(aProgress),
    157157          mServerProgress(aServerProgress),
    158           mpVM(NULL),
    159158          mpUVM(NULL),
    160159          mRC(E_FAIL),
     
    169168            mpSafeVMPtr = new Console::SafeVMPtr(aConsole);
    170169            if (mpSafeVMPtr->isOk())
    171             {
    172                 mpVM = mpSafeVMPtr->raw();
    173170                mpUVM = mpSafeVMPtr->rawUVM();
    174             }
    175171            else
    176172                mRC = mpSafeVMPtr->rc();
     
    201197    Utf8Str                     mErrorMsg;
    202198    const ComPtr<IProgress>     mServerProgress;
    203     PVM                         mpVM;
    204199    PUVM                        mpUVM;
    205200
     
    25472542
    25482543#ifdef VBOX_WITH_EXTPACK
    2549     int vrc = mptrExtPackManager->callAllVmPowerOnHooks(this, ptrVM.raw()); /** @todo called a few times too many... */
     2544    int vrc = mptrExtPackManager->callAllVmPowerOnHooks(this, VMR3GetVM(ptrVM.rawUVM())); /** @todo called a few times too many... */
    25502545#else
    25512546    int vrc = VINF_SUCCESS;
     
    61766171
    61776172
    6178 HRESULT Console::safeVMPtrRetainer(PVM *a_ppVM, PUVM *a_ppUVM, bool a_Quiet)
    6179 {
    6180     *a_ppVM  = NULL;
     6173HRESULT Console::safeVMPtrRetainer(PUVM *a_ppUVM, bool a_Quiet)
     6174{
    61816175    *a_ppUVM = NULL;
    61826176
     
    61906184    if (mVMDestroying) /* powerDown() is waiting for all callers to finish */
    61916185        return a_Quiet
    6192             ? E_ACCESSDENIED
    6193             : setError(E_ACCESSDENIED, tr("The virtual machine is being powered down"));
     6186             ? E_ACCESSDENIED
     6187             : setError(E_ACCESSDENIED, tr("The virtual machine is being powered down"));
    61946188    PUVM pUVM = mpUVM;
    61956189    if (!pUVM)
    61966190        return a_Quiet
    6197             ? E_ACCESSDENIED
    6198             : setError(E_ACCESSDENIED, tr("The virtual machine is powered off"));
     6191             ? E_ACCESSDENIED
     6192             : setError(E_ACCESSDENIED, tr("The virtual machine is powered off"));
    61996193
    62006194    /*
     
    62076201            : setError(E_ACCESSDENIED, tr("The virtual machine is powered off"));
    62086202
    6209     PVM pVM = VMR3GetVM(pUVM);
    6210     if (!pVM)
    6211     {
    6212         VMR3ReleaseUVM(pUVM);
    6213         return a_Quiet
    6214             ? E_ACCESSDENIED
    6215             : setError(E_ACCESSDENIED, tr("The virtual machine is powered off"));
    6216     }
    6217 
    62186203    /* done */
    6219     *a_ppVM  = pVM;
    62206204    *a_ppUVM = pUVM;
    62216205    return S_OK;
    62226206}
    62236207
    6224 void Console::safeVMPtrReleaser(PVM *a_ppVM, PUVM *a_ppUVM)
    6225 {
    6226     if (*a_ppVM && *a_ppUVM)
     6208void Console::safeVMPtrReleaser(PUVM *a_ppUVM)
     6209{
     6210    if (*a_ppUVM)
    62276211        VMR3ReleaseUVM(*a_ppUVM);
    6228     *a_ppVM  = NULL;
    62296212    *a_ppUVM = NULL;
    62306213}
  • trunk/src/VBox/Main/src-client/DisplayImpl.cpp

    r44382 r44402  
    29912991        return;
    29922992
    2993 #if DEBUG
     2993#ifdef VBOX_STRICT
    29942994    /*
    29952995     *  Sanity check. Note that this method may be called on EMT after Console
     
    30003000     *  time-critical method.
    30013001     */
    3002     Console::SafeVMPtrQuiet ptrVM (mParent);
     3002    Console::SafeVMPtrQuiet ptrVM(mParent);
    30033003    if (ptrVM.isOk())
    3004         Assert(VM_IS_EMT(ptrVM.raw()));
     3004    {
     3005        PVM pVM = VMR3GetVM(ptrVM.rawUVM());
     3006        Assert(VM_IS_EMT(pVM));
     3007    }
    30053008#endif
    30063009
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