VirtualBox

Changeset 29204 in vbox


Ignore:
Timestamp:
May 7, 2010 12:44:33 PM (15 years ago)
Author:
vboxsync
Message:

Main/Medium: improve r61220 (add forgotten medium registry save when deleting the storage representation of a medium)

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

Legend:

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

    r29149 r29204  
    21622162    if (FAILED(autoCaller.rc())) return autoCaller.rc();
    21632163
     2164    bool fNeedsSaveSettings = false;
    21642165    ComObjPtr <Progress> pProgress;
    21652166
    2166     HRESULT rc = deleteStorage(&pProgress, false /* aWait */,
    2167                                NULL /* pfNeedsSaveSettings */);
     2167    HRESULT rc = deleteStorage(&pProgress,
     2168                               false /* aWait */,
     2169                               &fNeedsSaveSettings);
     2170    if (fNeedsSaveSettings)
     2171    {
     2172        AutoWriteLock vboxlock(m->pVirtualBox COMMA_LOCKVAL_SRC_POS);
     2173        m->pVirtualBox->saveSettings();
     2174    }
     2175
    21682176    if (SUCCEEDED(rc))
    21692177        pProgress.queryInterfaceTo(aProgress);
     
    39113919         * which would have been broken if unregisterWithVirtualBox() failed
    39123920         * after we successfully deleted the storage) */
    3913         bool fNeedsSaveSettings = false;
    3914         rc = unregisterWithVirtualBox(&fNeedsSaveSettings);
     3921        rc = unregisterWithVirtualBox(pfNeedsSaveSettings);
    39153922        if (FAILED(rc))
    39163923            throw rc;
    3917         // no longer need lock, and below we might need the VirtualBox lock.
     3924        // no longer need lock
    39183925        multilock.release();
    3919         if (fNeedsSaveSettings)
    3920         {
    3921             AutoWriteLock vboxlock(m->pVirtualBox COMMA_LOCKVAL_SRC_POS);
    3922             m->pVirtualBox->saveSettings();
    3923         }
     3926
    39243927        // always set it to false because the medium registry is up to date
    39253928        if (pfNeedsSaveSettings)
  • trunk/src/VBox/Main/SnapshotImpl.cpp

    r29036 r29204  
    17141714
    17151715    bool stateRestored = false;
    1716     bool fNeedsSaveSettings = false;
     1716    bool fNeedsGlobalSaveSettings = false;
    17171717
    17181718    try
     
    17601760                                     1,
    17611761                                     false /* aOnline */,
    1762                                      &fNeedsSaveSettings);
     1762                                     &fNeedsGlobalSaveSettings);
    17631763            if (FAILED(rc))
    17641764                throw rc;
     
    18931893
    18941894        // save machine settings, reset the modified flag and commit;
    1895         rc = saveSettings(&fNeedsSaveSettings, SaveS_ResetCurStateModified | saveFlags);
     1895        rc = saveSettings(&fNeedsGlobalSaveSettings,
     1896                          SaveS_ResetCurStateModified | saveFlags);
    18961897        if (FAILED(rc))
    18971898            throw rc;
     
    19101911            HRESULT rc2 = pMedium->deleteStorage(NULL /* aProgress */,
    19111912                                                 true /* aWait */,
    1912                                                  &fNeedsSaveSettings);
     1913                                                 &fNeedsGlobalSaveSettings);
    19131914            // ignore errors here because we cannot roll back after saveSettings() above
    19141915            if (SUCCEEDED(rc2))
    19151916                pMedium->uninit();
    19161917        }
    1917 
    1918         if (fNeedsSaveSettings)
    1919         {
    1920             // finally, VirtualBox.xml needs saving too
    1921             AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
    1922             mParent->saveSettings();
    1923         }
    19241918    }
    19251919    catch (HRESULT aRC)
     
    19421936            updateMachineStateOnClient();
    19431937        }
     1938    }
     1939
     1940    if (fNeedsGlobalSaveSettings)
     1941    {
     1942        // finally, VirtualBox.xml needs saving too
     1943        AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
     1944        mParent->saveSettings();
    19441945    }
    19451946
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