VirtualBox

Changeset 47920 in vbox


Ignore:
Timestamp:
Aug 20, 2013 2:24:50 PM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
88227
Message:

Main/Medium: allow free form properties in the Special/ namespace, previously only properties defined by the VD backend were possible

File:
1 edited

Legend:

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

    r46720 r47920  
    23922392    }
    23932393
    2394     settings::StringsMap::iterator it = m->mapProperties.find(Utf8Str(aName));
    2395     if (it == m->mapProperties.end())
    2396         return setError(VBOX_E_OBJECT_NOT_FOUND,
    2397                         tr("Property '%ls' does not exist"),
    2398                         aName);
    2399 
    2400     it->second = aValue;
     2394    Utf8Str strName(aName);
     2395    Utf8Str strValue(aValue);
     2396    settings::StringsMap::iterator it = m->mapProperties.find(strName);
     2397    if (!strName.startsWith("Special/"))
     2398    {
     2399        if (it == m->mapProperties.end())
     2400            return setError(VBOX_E_OBJECT_NOT_FOUND,
     2401                            tr("Property '%s' does not exist"),
     2402                            strName.c_str());
     2403        it->second = strValue;
     2404    }
     2405    else
     2406    {
     2407        if (it == m->mapProperties.end())
     2408        {
     2409            if (!strValue.isEmpty())
     2410                m->mapProperties[strName] = strValue;
     2411        }
     2412        else
     2413        {
     2414            if (!strValue.isEmpty())
     2415                it->second = aValue;
     2416            else
     2417                m->mapProperties.erase(it);
     2418        }
     2419    }
    24012420
    24022421    // save the settings
     
    24612480         ++i)
    24622481    {
    2463         if (m->mapProperties.find(Utf8Str(names[i])) == m->mapProperties.end())
     2482        Utf8Str strName(names[i]);
     2483        if (   !strName.startsWith("Special/")
     2484            && m->mapProperties.find(strName) == m->mapProperties.end())
    24642485            return setError(VBOX_E_OBJECT_NOT_FOUND,
    2465                             tr("Property '%ls' does not exist"), names[i]);
     2486                            tr("Property '%s' does not exist"), strName.c_str());
    24662487    }
    24672488
     
    24712492         ++i)
    24722493    {
    2473         settings::StringsMap::iterator it = m->mapProperties.find(Utf8Str(names[i]));
    2474         AssertReturn(it != m->mapProperties.end(), E_FAIL);
    2475 
    2476         it->second = Utf8Str(values[i]);
     2494        Utf8Str strName(names[i]);
     2495        Utf8Str strValue(values[i]);
     2496        settings::StringsMap::iterator it = m->mapProperties.find(strName);
     2497        if (!strName.startsWith("Special/"))
     2498        {
     2499            AssertReturn(it != m->mapProperties.end(), E_FAIL);
     2500            it->second = strValue;
     2501        }
     2502        else
     2503        {
     2504            if (it == m->mapProperties.end())
     2505            {
     2506                if (!strValue.isEmpty())
     2507                    m->mapProperties[strName] = strValue;
     2508            }
     2509            else
     2510            {
     2511                if (!strValue.isEmpty())
     2512                    it->second = strValue;
     2513                else
     2514                    m->mapProperties.erase(it);
     2515            }
     2516        }
    24772517    }
    24782518
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