VirtualBox

Changeset 31223 in vbox


Ignore:
Timestamp:
Jul 29, 2010 4:15:25 PM (14 years ago)
Author:
vboxsync
Message:

Main: error handling in Machine::Unregister()

File:
1 edited

Legend:

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

    r31218 r31223  
    41264126                    llMedia.push_back(pMedium);
    41274127
    4128                 detachDevice(pAttach,
    4129                              alock,
    4130                              NULL /* pfNeedsSaveSettings */);
     4128                HRESULT rc = detachDevice(pAttach,
     4129                                          alock,
     4130                                          NULL /* pfNeedsSaveSettings */);
     4131                if (FAILED(rc))
     4132                    break;
    41314133            };
    41324134        }
     
    41374139    }
    41384140
     4141    if (FAILED(rc))
     4142    {
     4143        rollbackMedia();
     4144        return rc;
     4145    }
     4146
    41394147    // commit all the media changes made above
    41404148    commitMedia();
     
    41484156    {
    41494157        // now go thru the list of attached media reported by prepareUnregister() and close them all
    4150         size_t u = 0;
    41514158        for (MediaList::const_iterator it = llMedia.begin();
    41524159             it != llMedia.end();
     
    41594166            if (FAILED(autoCaller2.rc())) return autoCaller2.rc();
    41604167
    4161             pMedium->close(NULL /*fNeedsSaveSettings*/,     // we'll call saveSettings() in any case below
    4162                            autoCaller2);
     4168            ErrorInfoKeeper eik;
     4169            HRESULT rc = pMedium->close(NULL /*fNeedsSaveSettings*/,     // we'll call saveSettings() in any case below
     4170                                        autoCaller2);
    41634171                // this uninitializes the medium
    41644172
    4165             // report the path to the caller
    4166             llFilesForCaller.push_back(bstrFile);
    4167             ++u;
     4173            if (rc == VBOX_E_OBJECT_IN_USE)
     4174                // can happen if the medium was still attached to another machine;
     4175                // do not report the file to the caller then, but don't report
     4176                // an error either
     4177                eik.setNull();
     4178            else if (SUCCEEDED(rc))
     4179                // report the path to the caller
     4180                llFilesForCaller.push_back(bstrFile);
    41684181        }
    41694182    }
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