VirtualBox

Changeset 68048 in vbox


Ignore:
Timestamp:
Jul 19, 2017 3:02:01 PM (8 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
117072
Message:

Main/Settings.cpp: Use a "Description" XML tag instead of an attribute for the Medium registry entries. Matches what the code should've been doing since day 1 (and the XML schema), but unfortunately since VirtualBox 3.2 the code used the attribute. Not that there was any way to set the description in the API before 5.2.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/xml/Settings.cpp

    r67793 r68048  
    810810            throw ConfigFileError(this, &elmMedium, N_("Required %s/@location attribute is missing"), elmMedium.getName());
    811811
    812     elmMedium.getAttributeValue("Description", med.strDescription);       // optional
    813 
    814     // handle medium properties
    815     xml::NodesLoop nl2(elmMedium, "Property");
    816     const xml::ElementNode *pelmHDChild;
    817     while ((pelmHDChild = nl2.forAllNodes()))
    818     {
    819         Utf8Str strPropName, strPropValue;
    820         if (   pelmHDChild->getAttributeValue("name", strPropName)
    821             && pelmHDChild->getAttributeValue("value", strPropValue) )
    822             med.properties[strPropName] = strPropValue;
    823         else
    824             throw ConfigFileError(this, pelmHDChild, N_("Required HardDisk/Property/@name or @value attribute is missing"));
     812    // 3.2 builds added Description as an attribute, read it silently
     813    // and write it back as an element starting with 5.1.26
     814    elmMedium.getAttributeValue("Description", med.strDescription);
     815
     816    xml::NodesLoop nlMediumChildren(elmMedium);
     817    const xml::ElementNode *pelmMediumChild;
     818    while ((pelmMediumChild = nlMediumChildren.forAllNodes()))
     819    {
     820        if (pelmMediumChild->nameEquals("Description"))
     821            med.strDescription = pelmMediumChild->getValue();
     822        else if (pelmMediumChild->nameEquals("Property"))
     823        {
     824            // handle medium properties
     825            Utf8Str strPropName, strPropValue;
     826            if (   pelmMediumChild->getAttributeValue("name", strPropName)
     827                && pelmMediumChild->getAttributeValue("value", strPropValue) )
     828                med.properties[strPropName] = strPropValue;
     829            else
     830                throw ConfigFileError(this, pelmMediumChild, N_("Required HardDisk/Property/@name or @value attribute is missing"));
     831        }
    825832    }
    826833}
     
    12661273        pelmMedium->setAttribute("autoReset", mdm.fAutoReset);
    12671274    if (mdm.strDescription.length())
    1268         pelmMedium->setAttribute("Description", mdm.strDescription);
     1275        pelmMedium->createChild("Description")->addContent(mdm.strDescription);
    12691276
    12701277    for (StringsMap::const_iterator it = mdm.properties.begin();
     
    49574964        throw ConfigFileError(this, &elmSnapshot, N_("Required Snapshot/@name attribute is missing"));
    49584965
    4959     // earlier 3.1 trunk builds had a bug and added Description as an attribute, read it silently and write it back as an element
     4966    // 3.1 dev builds added Description as an attribute, read it silently
     4967    // and write it back as an element
    49604968    elmSnapshot.getAttributeValue("Description", snap.strDescription);
    49614969
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