VirtualBox

Changeset 11096 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Aug 4, 2008 12:15:41 PM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
34017
Message:

Main: deal with changing existing guest properties correctly (was using an invalid iterator)

File:
1 edited

Legend:

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

    r11093 r11096  
    27582758}
    27592759
    2760 STDMETHODIMP Machine::SetGuestProperty (INPTR BSTR aKey, INPTR BSTR aValue, INPTR BSTR aFlags)
     2760STDMETHODIMP Machine::SetGuestProperty (INPTR BSTR aName, INPTR BSTR aValue, INPTR BSTR aFlags)
    27612761{
    27622762#if !defined (VBOX_WITH_GUEST_PROPS)
    27632763    return E_NOTIMPL;
    27642764#else
    2765     if (!VALID_PTR (aKey))
     2765    if (!VALID_PTR (aName))
    27662766        return E_INVALIDARG;
    27672767    if ((aValue != NULL) && !VALID_PTR (aValue))
     
    27902790    {
    27912791        bool found = false;
    2792         HWData::GuestPropertyList::iterator targetIt = mHWData->mGuestProperties.end();
     2792        HWData::GuestProperty property;
    27932793        for (HWData::GuestPropertyList::iterator it = mHWData->mGuestProperties.begin();
    27942794             (it != mHWData->mGuestProperties.end()) && !found; ++it)
    2795             if (it->mName == aKey)
     2795            if (it->mName == aName)
    27962796            {
    2797                 targetIt = it;
     2797                property = *it;
     2798                mHWData.backup();
     2799                /* The backup() operation invalidates our iterator, so get a
     2800                 * new one. */
     2801                for (it = mHWData->mGuestProperties.begin();
     2802                     it->mName != aName; ++it);
     2803                mHWData->mGuestProperties.erase(it);
    27982804                found = true;
    27992805            }
    2800         if (targetIt != mHWData->mGuestProperties.end())
     2806        if (found)
     2807        {
     2808            if (NULL != aValue)
     2809            {
     2810                property.mValue = aValue;
     2811                property.mTimestamp = RTTimeMilliTS();
     2812                if (aFlags != NULL)
     2813                    property.mFlags = aFlags;
     2814                mHWData->mGuestProperties.push_back(property);
     2815            }
     2816        }
     2817        else if (aValue != NULL)
    28012818        {
    28022819            mHWData.backup();
    2803             if (NULL == aValue)
    2804                 mHWData->mGuestProperties.erase(targetIt);
    2805             else
    2806             {
    2807                 targetIt->mValue = aValue;
    2808                 targetIt->mTimestamp = RTTimeMilliTS();
    2809                 if (aFlags != NULL)
    2810                     targetIt->mFlags = aFlags;
    2811             }
    2812         }
    2813         else if (aValue != NULL)
    2814         {
    2815             mHWData.backup();
    2816             HWData::GuestProperty property;
    2817             property.mName = aKey;
     2820            property.mName = aName;
    28182821            property.mValue = aValue;
    28192822            property.mTimestamp = RTTimeMilliTS();
     
    28332836        BSTR dummy = NULL;
    28342837        ULONG64 dummy64;
    2835         rc = directControl->AccessGuestProperty (aKey, aValue, aFlags,
     2838        rc = directControl->AccessGuestProperty (aName, aValue, aFlags,
    28362839                                                 true /* isSetter */,
    28372840                                                 &dummy, &dummy64, &dummy);
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