VirtualBox

Changeset 22318 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
Aug 18, 2009 10:56:49 AM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
51201
Message:

handle required settings upgrade transparently in the settings backend only

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

Legend:

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

    r22304 r22318  
    14191419    mHWData.backup();
    14201420    mHWData->mAccelerate2DVideoEnabled = enable;
    1421 
    1422     // this feature may require an XML version bump
    1423     if (enable)
    1424         mData->m_pMachineConfigFile->setRequiredSettingsVersion(SettingsVersion_v1_8);
    14251421
    14261422    return S_OK;
  • trunk/src/VBox/Main/xml/Settings.cpp

    r22302 r22318  
    379379 * root "VirtualBox" element set up. This is used by both
    380380 * MainConfigFile and MachineConfigFile when writing out their XML.
     381 *
     382 * Before calling this, it is the responsibility of the caller to
     383 * set the "sv" member to the required settings version that is to
     384 * be written. For newly created files, the settings version will be
     385 * the latest (1.8); for files read in from disk earlier, it will be
     386 * the settings version indicated in the file. However, this method
     387 * will silently make sure that the settings version is always
     388 * at least 1.7 and change it if necessary, since there is no write
     389 * support for earlier settings versions.
    381390 */
    382391void ConfigFileBase::createStubDocument()
     
    388397    m->pelmRoot->setAttribute("xmlns", VBOX_XML_NAMESPACE);
    389398
    390     // we always write at least version 1.7; we write 1.8
    391     // if that was requested thru setRequiredSettingsVersion().
    392     // we make no attempt at writing earlier versions.
    393     // Writing 1.6 would be messy for machine files because
    394     // of the hard disk attachment changes which are not
    395     // necessarily backwards compatible and we don't want to
    396     // introduce complex logic to see whether they are.
    397399    const char *pcszVersion = NULL;
    398400    switch (m->sv)
     
    403405
    404406        default:
     407            // silently upgrade if necessary
    405408            pcszVersion = "1.7";
    406409            m->sv = SettingsVersion_v1_7;
     
    21972200void MachineConfigFile::write(const com::Utf8Str &strFilename)
    21982201{
     2202    // createStubDocument() sets the settings version to at least 1.7; however,
     2203    // we might need to enfore a later settings version if incompatible settings
     2204    // are present:
     2205    if (m->sv < SettingsVersion_v1_8)
     2206    {
     2207        if (hardwareMachine.fAccelerate2DVideo)
     2208            m->sv = SettingsVersion_v1_8;
     2209    }
     2210
    21992211    m->strFilename = strFilename;
    22002212    createStubDocument();
     
    22382250    clearDocument();
    22392251}
    2240 
    2241 /**
    2242  * Called from Main code if settings are enabled that require a new settings
    2243  * version. For example, if someone enables 2D video acceleration, which is a
    2244  * new feature with VirtualBox 3.1 and which requires settings version 1.8,
    2245  * COMSETTER(Accelerate2DVideoEnabled) calls this method to make sure
    2246  * at least settings version 1.8 is enabled.
    2247  *
    2248  * This allows us to preserve the settings format for older machines and
    2249  * break it only if necessary, on a per-machine basis.
    2250  * @param sv
    2251  */
    2252 void MachineConfigFile::setRequiredSettingsVersion(SettingsVersion_T sv)
    2253 {
    2254     if (m->sv < sv)
    2255         m->sv = sv;
    2256 }
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette