VirtualBox

Ignore:
Timestamp:
Oct 28, 2008 10:36:13 AM (16 years ago)
Author:
vboxsync
Message:

Main: First bulk of classes transfered to the new locking scheme.

File:
1 edited

Legend:

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

    r11296 r13606  
     1/* $Id $ */
     2
    13/** @file
    24 *
     
    57
    68/*
    7  * Copyright (C) 2006-2007 Sun Microsystems, Inc.
     9 * Copyright (C) 2006-2008 Sun Microsystems, Inc.
    810 *
    911 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    5254/////////////////////////////////////////////////////////////////////////////
    5355
     56DEFINE_EMPTY_CTOR_DTOR (Mouse)
     57
    5458HRESULT Mouse::FinalConstruct()
    5559{
    56     mParent = NULL;
    5760    mpDrv = NULL;
    5861    return S_OK;
     
    6164void Mouse::FinalRelease()
    6265{
    63     if (isReady())
    64         uninit();
     66    uninit();
    6567}
    6668
     
    7678HRESULT Mouse::init (Console *parent)
    7779{
    78     LogFlow(("Mouse::init(): isReady=%d\n", isReady()));
     80    LogFlow(("Mouse::init()\n"));
    7981
    8082    ComAssertRet (parent, E_INVALIDARG);
    8183
    82     AutoWriteLock alock (this);
    83     ComAssertRet (!isReady(), E_UNEXPECTED);
    84 
    85     mParent = parent;
     84    /* Enclose the state transition NotReady->InInit->Ready */
     85    AutoInitSpan autoInitSpan (this);
     86    AssertReturn (autoInitSpan.isOk(), E_UNEXPECTED);
     87
     88    unconst(mParent) = parent;
    8689
    8790#ifdef RT_OS_L4
     
    9295#endif
    9396
    94     setReady (true);
     97    /* Confirm a successful initialization */
     98    autoInitSpan.setSucceeded();
     99
    95100    return S_OK;
    96101}
     
    102107void Mouse::uninit()
    103108{
    104     LogFlow(("Mouse::uninit(): isReady=%d\n", isReady()));
    105 
    106     AutoWriteLock alock (this);
    107     AssertReturn (isReady(), (void) 0);
     109    LogFlowThisFunc (("\n"));
     110
     111    /* Enclose the state transition Ready->InUninit->NotReady */
     112    AutoUninitSpan autoUninitSpan (this);
     113    if (autoUninitSpan.uninitDone())
     114        return;
    108115
    109116    if (mpDrv)
     
    111118    mpDrv = NULL;
    112119
    113     setReady (false);
     120    unconst (mParent).setNull();
    114121}
    115122
     
    129136        return E_POINTER;
    130137
     138    AutoCaller autoCaller (this);
     139    CheckComRCReturnRC (autoCaller.rc());
     140
    131141    AutoWriteLock alock (this);
    132     CHECK_READY();
    133142
    134143    CHECK_CONSOLE_DRV (mpDrv);
     
    141150    mParent->getVMMDev()->getVMMDevPort()->pfnQueryMouseCapabilities(mParent->getVMMDev()->getVMMDevPort(), &mouseCaps);
    142151    *absoluteSupported = mouseCaps & VMMDEV_MOUSEGUESTWANTSABS;
     152
    143153    return S_OK;
    144154}
     
    156166        return E_POINTER;
    157167
     168    AutoCaller autoCaller (this);
     169    CheckComRCReturnRC (autoCaller.rc());
     170
    158171    AutoWriteLock alock (this);
    159     CHECK_READY();
    160172
    161173    CHECK_CONSOLE_DRV (mpDrv);
     
    168180    mParent->getVMMDev()->getVMMDevPort()->pfnQueryMouseCapabilities(mParent->getVMMDev()->getVMMDevPort(), &mouseCaps);
    169181    *needsHostCursor = mouseCaps & VMMDEV_MOUSEGUESTNEEDSHOSTCUR;
     182
    170183    return S_OK;
    171184}
     
    185198STDMETHODIMP Mouse::PutMouseEvent(LONG dx, LONG dy, LONG dz, LONG buttonState)
    186199{
     200    HRESULT rc = S_OK;
     201
     202    AutoCaller autoCaller (this);
     203    CheckComRCReturnRC (autoCaller.rc());
     204
    187205    AutoWriteLock alock (this);
    188     CHECK_READY();
    189206
    190207    CHECK_CONSOLE_DRV (mpDrv);
     
    218235    int vrc = mpDrv->pUpPort->pfnPutEvent(mpDrv->pUpPort, dx, dy, dz, fButtons);
    219236    if (VBOX_FAILURE (vrc))
    220         return setError (E_FAIL,
    221             tr ("Could not send the mouse event to the virtual mouse (%Vrc)"),
    222             vrc);
    223 
    224     return S_OK;
     237        rc = setError (E_FAIL, tr ("Could not send the mouse event to the virtual mouse (%Vrc)"),
     238                       vrc);
     239
     240    return rc;
    225241}
    226242
     
    238254                                          LONG buttonState)
    239255{
     256    HRESULT rc = S_OK;
     257
     258    AutoCaller autoCaller (this);
     259    CheckComRCReturnRC (autoCaller.rc());
     260
    240261    AutoWriteLock alock (this);
    241     CHECK_READY();
    242262
    243263    CHECK_CONSOLE_DRV (mpDrv);
     
    267287    ULONG displayWidth;
    268288    ULONG displayHeight;
    269     HRESULT rc = pDisplay->COMGETTER(Width)(&displayWidth);
     289    rc = pDisplay->COMGETTER(Width)(&displayWidth);
    270290    ComAssertComRCRet (rc, rc);
    271291    rc = pDisplay->COMGETTER(Height)(&displayHeight);
     
    297317                                          fButtons);
    298318        if (VBOX_FAILURE (vrc))
    299             return setError (E_FAIL,
    300                 tr ("Could not send the mouse event to the virtual mouse (%Vrc)"),
    301                 vrc);
    302     }
    303 
    304     return S_OK;
     319            rc = setError (E_FAIL, tr ("Could not send the mouse event to the virtual mouse (%Vrc)"),
     320                           vrc);
     321    }
     322
     323    return rc;
    305324}
    306325
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