VirtualBox

Ignore:
Timestamp:
Dec 11, 2008 7:37:55 PM (16 years ago)
Author:
vboxsync
Message:

Main: #3377: Implicitly detach DVD/Floppy from an unregistered machine (as opposed to hard disks, this does not have side effects).

File:
1 edited

Legend:

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

    r15051 r15334  
    275275            if (SUCCEEDED (rc))
    276276            {
    277                 mData.backup();
    278 
    279                 unmount();
    280 
    281                 mData->mImage = image;
    282                 mData->mState = DriveState_ImageMounted;
    283 
    284                 /* leave the lock before informing callbacks */
    285                 alock.unlock();
    286 
    287                 mParent->onDVDDriveChange();
     277                /* umount() will backup data */
     278                rc = unmount();
     279                if (SUCCEEDED (rc))
     280                {
     281                    mData->mImage = image;
     282                    mData->mState = DriveState_ImageMounted;
     283
     284                    /* leave the lock before informing callbacks */
     285                    alock.unlock();
     286
     287                    mParent->onDVDDriveChange();
     288                }
    288289            }
    289290        }
     
    309310        !mData->mHostDrive.equalsTo (aHostDVDDrive))
    310311    {
    311         mData.backup();
    312 
    313         unmount();
    314 
    315         mData->mHostDrive = aHostDVDDrive;
    316         mData->mState = DriveState_HostDriveCaptured;
    317 
    318         /* leave the lock before informing callbacks */
    319         alock.unlock();
    320 
    321         mParent->onDVDDriveChange();
     312        /* umount() will backup data */
     313        HRESULT rc = unmount();
     314        if (SUCCEEDED (rc))
     315        {
     316            mData->mHostDrive = aHostDVDDrive;
     317            mData->mState = DriveState_HostDriveCaptured;
     318
     319            /* leave the lock before informing callbacks */
     320            alock.unlock();
     321
     322            mParent->onDVDDriveChange();
     323        }
    322324    }
    323325
     
    338340    if (mData->mState != DriveState_NotMounted)
    339341    {
    340         mData.backup();
    341 
    342         unmount();
    343 
    344         mData->mState = DriveState_NotMounted;
    345 
    346         /* leave the lock before informing callbacks */
    347         alock.unlock();
    348 
    349         mParent->onDVDDriveChange();
     342        /* umount() will backup data */
     343        HRESULT rc = unmount();
     344        if (SUCCEEDED (rc))
     345        {
     346            mData->mState = DriveState_NotMounted;
     347
     348            /* leave the lock before informing callbacks */
     349            alock.unlock();
     350
     351            mParent->onDVDDriveChange();
     352        }
    350353    }
    351354
     
    385388
    386389/**
    387  *  Loads settings from the given machine node.
    388  *  May be called once right after this object creation.
    389  *
    390  *  @param aMachineNode <Machine> node.
    391  *
    392  *  @note Locks this object for writing.
     390 * Loads settings from the given machine node. May be called once right after
     391 * this object creation.
     392 *
     393 * @param aMachineNode <Machine> node.
     394 *
     395 * @note Locks this object for writing.
    393396 */
    394397HRESULT DVDDrive::loadSettings (const settings::Key &aMachineNode)
     
    469472
    470473/**
    471  *  Saves settings to the given machine node.
    472  *
    473  *  @param aMachineNode <Machine> node.
    474  *
    475  *  @note Locks this object for reading.
     474 * Saves settings to the given machine node.
     475 *
     476 * @param aMachineNode <Machine> node.
     477 *
     478 * @note Locks this object for reading.
    476479 */
    477480HRESULT DVDDrive::saveSettings (settings::Key &aMachineNode)
     
    530533
    531534/**
    532  *  @note Locks this object for writing.
     535 * @note Locks this object for writing.
    533536 */
    534537bool DVDDrive::rollback()
     
    567570
    568571/**
    569  *  @note Locks this object for writing, together with the peer object (also
    570  *  for writing) if there is one.
     572 * @note Locks this object for writing, together with the peer object (also for
     573 *      writing) if there is one.
    571574 */
    572575void DVDDrive::commit()
     
    605608
    606609/**
    607  *  @note Locks this object for writing, together with the peer object
    608  *  represented by @a aThat (locked for reading).
     610 * @note Locks this object for writing, together with the peer object
     611 *       represented by @a aThat (locked for reading).
    609612 */
    610613void DVDDrive::copyFrom (DVDDrive *aThat)
     
    628631}
    629632
    630 // private methods
    631 ////////////////////////////////////////////////////////////////////////////////
    632 
    633 /**
    634  *  Helper to unmount a drive.
    635  *
    636  *  @return COM status code
    637  *
     633/**
     634 * Helper to unmount a drive.
     635 *
     636 * @note Must be called from under this object's write lock.
    638637 */
    639638HRESULT DVDDrive::unmount()
    640639{
    641640    AssertReturn (isWriteLockOnCurrentThread(), E_FAIL);
     641
     642    mData.backup();
    642643
    643644    if (mData->mImage)
     
    646647        mData->mHostDrive.setNull();
    647648
    648     return S_OK;
    649 }
     649    mData->mState = DriveState_NotMounted;
     650
     651    return S_OK;
     652}
     653
     654// private methods
     655////////////////////////////////////////////////////////////////////////////////
     656
    650657/* vi: set tabstop=4 shiftwidth=4 expandtab: */
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