VirtualBox

Changeset 38996 in vbox for trunk/src/VBox/Main/src-server


Ignore:
Timestamp:
Oct 14, 2011 12:59:50 PM (13 years ago)
Author:
vboxsync
Message:

Main: fix setting the current state modification flag in some circumstances

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

Legend:

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

    r38887 r38996  
    106106Machine::Data::Data()
    107107{
    108     mRegistered = FALSE;
    109     pMachineConfigFile = NULL;
    110     flModifications = 0;
    111     mAccessible = FALSE;
     108    mRegistered                = FALSE;
     109    pMachineConfigFile         = NULL;
     110    /* Contains hints on what has changed when the user is using the VM (config
     111     * changes, running the VM, ...). This is used to decide if a config needs
     112     * to be written to disk. */
     113    flModifications            = 0;
     114    /* VM modification usually also trigger setting the current state to
     115     * "Modified". Although this is not always the case. An e.g. is the VM
     116     * initialization phase or when snapshot related data is changed. The
     117     * actually behavior is controlled by the following flag. */
     118    m_fAllowStateModification  = false;
     119    mAccessible                = FALSE;
    112120    /* mUuid is initialized in Machine::init() */
    113121
    114     mMachineState = MachineState_PoweredOff;
     122    mMachineState              = MachineState_PoweredOff;
    115123    RTTimeNow(&mLastStateChange);
    116124
    117     mMachineStateDeps = 0;
    118     mMachineStateDepsSem = NIL_RTSEMEVENTMULTI;
     125    mMachineStateDeps          = 0;
     126    mMachineStateDepsSem       = NIL_RTSEMEVENTMULTI;
    119127    mMachineStateChangePending = 0;
    120128
    121     mCurrentStateModified = TRUE;
    122     mGuestPropertiesModified = FALSE;
    123 
    124     mSession.mPid = NIL_RTPROCESS;
    125     mSession.mState = SessionState_Unlocked;
     129    mCurrentStateModified      = TRUE;
     130    mGuestPropertiesModified   = FALSE;
     131
     132    mSession.mPid              = NIL_RTPROCESS;
     133    mSession.mState            = SessionState_Unlocked;
    126134}
    127135
     
    327335        }
    328336
     337        /* At this point the changing of the current state modification
     338         * flag is allowed. */
     339        allowStateModification();
     340
    329341        /* commit all changes made during the initialization */
    330342        commit();
     
    425437                if (FAILED(rc)) throw rc;
    426438
     439                /* At this point the changing of the current state modification
     440                 * flag is allowed. */
     441                allowStateModification();
     442
    427443                commit();
    428444            }
     
    464480}
    465481
     482#include <iprt/cpp/autores.h>
    466483/**
    467484 *  Initializes a new instance from a machine config that is already in memory
     
    518535        mUserData->s.strName = strName;
    519536
    520         /* commit all changes made during the initialization */
    521537        if (SUCCEEDED(rc))
     538        {
     539            /* At this point the changing of the current state modification
     540             * flag is allowed. */
     541            allowStateModification();
     542
     543            /* commit all changes made during the initialization */
    522544            commit();
     545        }
    523546    }
    524547
     
    63346357 * @param fl
    63356358 */
    6336 void Machine::setModified(uint32_t fl)
     6359void Machine::setModified(uint32_t fl, bool fAllowStateModification /* = true */)
    63376360{
    63386361    mData->flModifications |= fl;
    6339     mData->mCurrentStateModified = true;
     6362    if (fAllowStateModification && isStateModificationAllowed())
     6363        mData->mCurrentStateModified = true;
    63406364}
    63416365
     
    63466370 * @param   fModifications      The flag to add.
    63476371 */
    6348 void Machine::setModifiedLock(uint32_t fModification)
     6372void Machine::setModifiedLock(uint32_t fModification, bool fAllowStateModification /* = true */)
    63496373{
    63506374    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    6351     setModified(fModification);
     6375    setModified(fModification, fAllowStateModification);
    63526376}
    63536377
  • trunk/src/VBox/Main/src-server/SnapshotImpl.cpp

    r38818 r38996  
    12251225    bool fNeedsGlobalSaveSettings = false;
    12261226
    1227     // flag the machine as dirty or change won't get saved
    1228     mPeer->setModified(Machine::IsModified_Snapshots);
     1227    /* Flag the machine as dirty or change won't get saved. We disable the
     1228     * modification of the current state flag, cause this snapshot data isn't
     1229     * related to the current state. */
     1230    mPeer->setModified(Machine::IsModified_Snapshots, false /* fAllowStateModification */);
    12291231    HRESULT rc = mPeer->saveSettings(&fNeedsGlobalSaveSettings,
    12301232                                     SaveS_Force);        // we know we need saving, no need to check
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