- Timestamp:
- Jul 8, 2009 3:19:42 PM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 49780
- Location:
- trunk
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/ministring_cpp.h
r21394 r21404 35 35 #include <iprt/string.h> 36 36 37 #include <new> 38 37 39 /** 38 40 * "ministring" is a small C++ string class that does not depend on anything … … 125 127 { 126 128 m_psz = (char*)RTMemRealloc(m_psz, cb); 129 #ifdef RT_EXCEPTIONS_ENABLED 130 if (!m_psz) 131 throw std::bad_alloc(); 132 #endif 127 133 m_cbAllocated = cb; 128 134 } … … 255 261 { 256 262 return length() == 0; 257 }258 259 /**260 * Returns true if no memory is currently allocated.261 * @return262 */263 bool isNull() const264 {265 return m_psz == NULL;266 263 } 267 264 … … 349 346 m_cbAllocated = m_cbLength + 1; 350 347 m_psz = (char*)RTMemAlloc(m_cbAllocated); 348 #ifdef RT_EXCEPTIONS_ENABLED 349 if (!m_psz) 350 throw std::bad_alloc(); 351 #endif 351 352 memcpy(m_psz, s.m_psz, m_cbAllocated); // include 0 terminator 352 353 } … … 374 375 m_cbAllocated = m_cbLength + 1; 375 376 m_psz = (char*)RTMemAlloc(m_cbAllocated); 377 #ifdef RT_EXCEPTIONS_ENABLED 378 if (!m_psz) 379 throw std::bad_alloc(); 380 #endif 376 381 memcpy(m_psz, pcsz, m_cbAllocated); // include 0 terminator 377 382 } -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageGuestProp.cpp
r21394 r21404 167 167 { 168 168 HRESULT rc = S_OK; 169 Utf8Str utf8Name 169 Utf8Str utf8Name(name); 170 170 Guid uuid(machineId); 171 if (utf8Name.isNull())172 rc = E_OUTOFMEMORY;173 171 if ( SUCCEEDED (rc) 174 172 && uuid == mUuid -
trunk/src/VBox/Main/ApplianceImpl.cpp
r21394 r21404 1475 1475 1476 1476 /* Audio */ 1477 if (!vsysThis.strSoundCardType.is Null())1477 if (!vsysThis.strSoundCardType.isEmpty()) 1478 1478 /* Currently we set the AC97 always. 1479 1479 @todo: figure out the hardware which could be possible */ -
trunk/src/VBox/Main/ConsoleImpl.cpp
r21394 r21404 1084 1084 for (unsigned i = 0; i < 10 && (VERR_BUFFER_OVERFLOW == vrc); ++i) 1085 1085 { 1086 Utf8Buf.reserve(cchBuf + 1024); 1087 if (Utf8Buf.isNull()) 1086 try 1087 { 1088 Utf8Buf.reserve(cchBuf + 1024); 1089 } 1090 catch(...) 1091 { 1088 1092 return E_OUTOFMEMORY; 1093 } 1089 1094 parm[1].type = VBOX_HGCM_SVC_PARM_PTR; 1090 1095 parm[1].u.pointer.addr = Utf8Buf.mutableRaw(); … … 3871 3876 using namespace guestProp; 3872 3877 3873 VBOXHGCMSVCPARM parm[4]; 3874 Utf8Str Utf8Name = aName; 3875 AssertReturn(!Utf8Name.isNull(), E_OUTOFMEMORY); 3876 char pszBuffer[MAX_VALUE_LEN + MAX_FLAGS_LEN]; 3877 3878 parm[0].type = VBOX_HGCM_SVC_PARM_PTR; 3879 parm[0].u.pointer.addr = (void*)Utf8Name.c_str(); 3880 /* The + 1 is the null terminator */ 3881 parm[0].u.pointer.size = (uint32_t)Utf8Name.length() + 1; 3882 parm[1].type = VBOX_HGCM_SVC_PARM_PTR; 3883 parm[1].u.pointer.addr = pszBuffer; 3884 parm[1].u.pointer.size = sizeof(pszBuffer); 3885 int vrc = mVMMDev->hgcmHostCall ("VBoxGuestPropSvc", GET_PROP_HOST, 3886 4, &parm[0]); 3887 /* The returned string should never be able to be greater than our buffer */ 3888 AssertLogRel (vrc != VERR_BUFFER_OVERFLOW); 3889 AssertLogRel (RT_FAILURE(vrc) || VBOX_HGCM_SVC_PARM_64BIT == parm[2].type); 3890 if (RT_SUCCESS (vrc) || (VERR_NOT_FOUND == vrc)) 3891 { 3892 rc = S_OK; 3893 if (vrc != VERR_NOT_FOUND) 3894 { 3895 Utf8Str strBuffer(pszBuffer); 3896 strBuffer.cloneTo(aValue); 3897 3898 *aTimestamp = parm[2].u.uint64; 3899 3900 size_t iFlags = strBuffer.length() + 1; 3901 Utf8Str(pszBuffer + iFlags).cloneTo(aFlags); 3878 try 3879 { 3880 VBOXHGCMSVCPARM parm[4]; 3881 Utf8Str Utf8Name = aName; 3882 char pszBuffer[MAX_VALUE_LEN + MAX_FLAGS_LEN]; 3883 3884 parm[0].type = VBOX_HGCM_SVC_PARM_PTR; 3885 parm[0].u.pointer.addr = (void*)Utf8Name.c_str(); 3886 /* The + 1 is the null terminator */ 3887 parm[0].u.pointer.size = (uint32_t)Utf8Name.length() + 1; 3888 parm[1].type = VBOX_HGCM_SVC_PARM_PTR; 3889 parm[1].u.pointer.addr = pszBuffer; 3890 parm[1].u.pointer.size = sizeof(pszBuffer); 3891 int vrc = mVMMDev->hgcmHostCall ("VBoxGuestPropSvc", GET_PROP_HOST, 3892 4, &parm[0]); 3893 /* The returned string should never be able to be greater than our buffer */ 3894 AssertLogRel (vrc != VERR_BUFFER_OVERFLOW); 3895 AssertLogRel (RT_FAILURE(vrc) || VBOX_HGCM_SVC_PARM_64BIT == parm[2].type); 3896 if (RT_SUCCESS (vrc) || (VERR_NOT_FOUND == vrc)) 3897 { 3898 rc = S_OK; 3899 if (vrc != VERR_NOT_FOUND) 3900 { 3901 Utf8Str strBuffer(pszBuffer); 3902 strBuffer.cloneTo(aValue); 3903 3904 *aTimestamp = parm[2].u.uint64; 3905 3906 size_t iFlags = strBuffer.length() + 1; 3907 Utf8Str(pszBuffer + iFlags).cloneTo(aFlags); 3908 } 3909 else 3910 aValue = NULL; 3902 3911 } 3903 3912 else 3904 aValue = NULL; 3905 } 3906 else 3907 rc = setError (E_UNEXPECTED, 3908 tr ("The service call failed with the error %Rrc"), vrc); 3913 rc = setError (E_UNEXPECTED, 3914 tr ("The service call failed with the error %Rrc"), vrc); 3915 } 3916 catch(std::bad_alloc &e) 3917 { 3918 rc = E_OUTOFMEMORY; 3919 } 3909 3920 return rc; 3910 3921 #endif /* else !defined (VBOX_WITH_GUEST_PROPS) */ … … 4392 4403 4393 4404 /* make sure the Logs folder exists */ 4394 Assert (!logDir.isEmpty());4405 Assert(logDir.length()); 4395 4406 if (!RTDirExists (logDir)) 4396 4407 RTDirCreateFullPath (logDir, 0777); … … 6191 6202 6192 6203 /* append to the existing error message if any */ 6193 if ( !task->mErrorMsg.isEmpty())6204 if (task->mErrorMsg.length()) 6194 6205 task->mErrorMsg = Utf8StrFmt ("%s.\n%N (%Rrc)", task->mErrorMsg.raw(), 6195 6206 pszFormat, &va2, rc, rc); … … 6666 6677 6667 6678 /* Load saved state? */ 6668 if ( !task->mSavedStateFile.isEmpty())6679 if (task->mSavedStateFile.length()) 6669 6680 { 6670 6681 LogFlowFunc (("Restoring saved state from '%s'...\n", … … 6749 6760 * this function is not updated. 6750 6761 */ 6751 if ( task->mErrorMsg.isNull())6762 if (!task->mErrorMsg.length()) 6752 6763 { 6753 6764 /* If the error message is not set but we've got a failure, … … 7095 7106 AssertReturn (task.get(), VERR_INVALID_PARAMETER); 7096 7107 7097 Assert (!task->mSavedStateFile.isNull());7098 Assert 7108 Assert(task->mSavedStateFile.length()); 7109 Assert(!task->mProgress.isNull()); 7099 7110 7100 7111 const ComObjPtr <Console> &that = task->mConsole; … … 7252 7263 else 7253 7264 { 7254 if (!errMsg.isNull()) 7255 task->mProgress->notifyComplete (rc, 7256 COM_IIDOF(IConsole), Console::getComponentName(), errMsg); 7265 if (errMsg.length()) 7266 task->mProgress->notifyComplete(rc, 7267 COM_IIDOF(IConsole), 7268 Console::getComponentName(), 7269 errMsg); 7257 7270 else 7258 7271 task->mProgress->notifyComplete (rc); -
trunk/src/VBox/Main/ConsoleImpl2.cpp
r21394 r21404 1801 1801 * Guest property service 1802 1802 */ 1803 try 1803 1804 { 1804 1805 /* Load the service */ … … 1844 1845 timestamps.push_back(timestampsOut[i]); 1845 1846 utf8Flags.push_back(Bstr(flagsOut[i])); 1846 #if 0 /** @todo r=bird: Who is gonna catch this? Why does it trigger now? */1847 if ( utf8Names.back().isNull()1848 || utf8Values.back().isNull()1849 || utf8Flags.back().isNull()1850 )1851 throw std::bad_alloc();1852 #endif1853 1847 } 1854 1848 for (unsigned i = 0; i < cProps && RT_SUCCESS(rc); ++i) … … 1889 1883 Log(("Set VBoxGuestPropSvc property store\n")); 1890 1884 } 1885 } 1886 catch(std::bad_alloc &e) 1887 { 1888 return VERR_NO_MEMORY; 1891 1889 } 1892 1890 #endif /* VBOX_WITH_GUEST_PROPS defined */ -
trunk/src/VBox/Main/DHCPServerRunner.cpp
r21394 r21404 97 97 for (unsigned i = 0; i < DHCPCFG_NOTOPT_MAXVAL; i++) 98 98 { 99 if ( !mOptions[i].isNull())99 if (mOptions[i].length()) 100 100 { 101 101 const ARGDEF * pArgDef = getArgDef((DHCPCFG)i); 102 args[index++] = pArgDef->Name; 103 if (!mOptions[i].isEmpty()) 104 { 105 args[index++] = mOptions[i].raw(); 106 } 102 args[index++] = pArgDef->Name; // e.g. "--network" 103 args[index++] = mOptions[i].raw(); // value 107 104 } 108 105 } -
trunk/src/VBox/Main/MachineImpl.cpp
r21394 r21404 2780 2780 Utf8Str logFolder; 2781 2781 getLogFolder (logFolder); 2782 Assert (!logFolder.isEmpty());2783 if (RTDirExists 2782 Assert(logFolder.length()); 2783 if (RTDirExists(logFolder)) 2784 2784 { 2785 2785 /* Delete all VBox.log[.N] files from the Logs folder … … 2805 2805 * there (we don't check for errors because the user might have 2806 2806 * some private files there that we don't want to delete) */ 2807 Utf8Str snapshotFolder = mUserData->mSnapshotFolderFull;2808 Assert (!snapshotFolder.isEmpty());2809 if (RTDirExists 2810 RTDirRemove 2807 Utf8Str snapshotFolder(mUserData->mSnapshotFolderFull); 2808 Assert(snapshotFolder.length()); 2809 if (RTDirExists(snapshotFolder)) 2810 RTDirRemove(snapshotFolder); 2811 2811 2812 2812 /* delete the directory that contains the settings file, but only … … 3056 3056 } 3057 3057 3058 STDMETHODIMP Machine::SetGuestProperty (IN_BSTR aName, IN_BSTR aValue, IN_BSTR aFlags) 3058 STDMETHODIMP Machine::SetGuestProperty(IN_BSTR aName, 3059 IN_BSTR aValue, 3060 IN_BSTR aFlags) 3059 3061 { 3060 3062 #if !defined (VBOX_WITH_GUEST_PROPS) … … 3068 3070 return E_INVALIDARG; 3069 3071 3070 Utf8Str utf8Name (aName); 3071 Utf8Str utf8Flags (aFlags); 3072 Utf8Str utf8Patterns (mHWData->mGuestPropertyNotificationPatterns); 3073 if ( utf8Name.isNull() 3074 || ((aFlags != NULL) && utf8Flags.isNull()) 3075 || utf8Patterns.isNull() 3076 ) 3077 return E_OUTOFMEMORY; 3078 bool matchAll = false; 3079 if (0 == utf8Patterns.length()) 3080 matchAll = true; 3081 3082 uint32_t fFlags = NILFLAG; 3083 if ((aFlags != NULL) && RT_FAILURE (validateFlags (utf8Flags.raw(), &fFlags)) 3084 ) 3085 return setError (E_INVALIDARG, tr ("Invalid flag values: '%ls'"), 3086 aFlags); 3087 3088 AutoCaller autoCaller (this); 3089 CheckComRCReturnRC (autoCaller.rc()); 3090 3091 AutoWriteLock alock (this); 3092 3093 HRESULT rc = checkStateDependency (MutableStateDep); 3094 CheckComRCReturnRC (rc); 3095 3096 rc = S_OK; 3097 3098 if (!mHWData->mPropertyServiceActive) 3099 { 3100 bool found = false; 3101 HWData::GuestProperty property; 3102 property.mFlags = NILFLAG; 3103 if (fFlags & TRANSIENT) 3104 rc = setError (VBOX_E_INVALID_OBJECT_STATE, 3105 tr ("Cannot set a transient property when the " 3106 "machine is not running")); 3107 if (SUCCEEDED (rc)) 3108 { 3109 for (HWData::GuestPropertyList::iterator it = 3110 mHWData->mGuestProperties.begin(); 3111 it != mHWData->mGuestProperties.end(); ++ it) 3112 if (it->mName == aName) 3072 HRESULT rc = S_OK; 3073 3074 try 3075 { 3076 Utf8Str utf8Name(aName); 3077 Utf8Str utf8Flags(aFlags); 3078 Utf8Str utf8Patterns(mHWData->mGuestPropertyNotificationPatterns); 3079 3080 bool matchAll = false; 3081 if (utf8Patterns.isEmpty()) 3082 matchAll = true; 3083 3084 uint32_t fFlags = NILFLAG; 3085 if ( (aFlags != NULL) 3086 && RT_FAILURE (validateFlags (utf8Flags.raw(), &fFlags)) 3087 ) 3088 return setError(E_INVALIDARG, 3089 tr("Invalid flag values: '%ls'"), 3090 aFlags); 3091 3092 AutoCaller autoCaller(this); 3093 CheckComRCReturnRC(autoCaller.rc()); 3094 3095 AutoWriteLock alock(this); 3096 3097 rc = checkStateDependency(MutableStateDep); 3098 CheckComRCReturnRC (rc); 3099 3100 rc = S_OK; 3101 3102 if (!mHWData->mPropertyServiceActive) 3103 { 3104 bool found = false; 3105 HWData::GuestProperty property; 3106 property.mFlags = NILFLAG; 3107 if (fFlags & TRANSIENT) 3108 rc = setError(VBOX_E_INVALID_OBJECT_STATE, 3109 tr("Cannot set a transient property when the machine is not running")); 3110 3111 if (SUCCEEDED (rc)) 3112 { 3113 for (HWData::GuestPropertyList::iterator it = 3114 mHWData->mGuestProperties.begin(); 3115 it != mHWData->mGuestProperties.end(); ++ it) 3116 if (it->mName == aName) 3117 { 3118 property = *it; 3119 if (it->mFlags & (RDONLYHOST)) 3120 rc = setError (E_ACCESSDENIED, 3121 tr ("The property '%ls' cannot be changed by the host"), 3122 aName); 3123 else 3124 { 3125 mHWData.backup(); 3126 /* The backup() operation invalidates our iterator, so 3127 * get a new one. */ 3128 for (it = mHWData->mGuestProperties.begin(); 3129 it->mName != aName; ++ it) 3130 ; 3131 mHWData->mGuestProperties.erase (it); 3132 } 3133 found = true; 3134 break; 3135 } 3136 } 3137 if (found && SUCCEEDED (rc)) 3138 { 3139 if (*aValue) 3113 3140 { 3114 property = *it; 3115 if (it->mFlags & (RDONLYHOST)) 3116 rc = setError (E_ACCESSDENIED, 3117 tr ("The property '%ls' cannot be changed by the host"), 3118 aName); 3119 else 3120 { 3121 mHWData.backup(); 3122 /* The backup() operation invalidates our iterator, so 3123 * get a new one. */ 3124 for (it = mHWData->mGuestProperties.begin(); 3125 it->mName != aName; ++ it) 3126 ; 3127 mHWData->mGuestProperties.erase (it); 3128 } 3129 found = true; 3130 break; 3141 RTTIMESPEC time; 3142 property.mValue = aValue; 3143 property.mTimestamp = RTTimeSpecGetNano (RTTimeNow (&time)); 3144 if (aFlags != NULL) 3145 property.mFlags = fFlags; 3146 mHWData->mGuestProperties.push_back (property); 3131 3147 } 3132 } 3133 if (found && SUCCEEDED (rc)) 3134 { 3135 if (*aValue) 3148 } 3149 else if (SUCCEEDED (rc) && *aValue) 3136 3150 { 3137 3151 RTTIMESPEC time; 3152 mHWData.backup(); 3153 property.mName = aName; 3138 3154 property.mValue = aValue; 3139 3155 property.mTimestamp = RTTimeSpecGetNano (RTTimeNow (&time)); 3140 if (aFlags != NULL) 3141 property.mFlags = fFlags; 3156 property.mFlags = fFlags; 3142 3157 mHWData->mGuestProperties.push_back (property); 3143 3158 } 3144 } 3145 else if (SUCCEEDED (rc) && *aValue) 3146 { 3147 RTTIMESPEC time; 3148 mHWData.backup(); 3149 property.mName = aName; 3150 property.mValue = aValue; 3151 property.mTimestamp = RTTimeSpecGetNano (RTTimeNow (&time)); 3152 property.mFlags = fFlags; 3153 mHWData->mGuestProperties.push_back (property); 3154 } 3155 if ( SUCCEEDED (rc) 3156 && ( matchAll 3157 || RTStrSimplePatternMultiMatch (utf8Patterns.raw(), RTSTR_MAX, 3158 utf8Name.raw(), RTSTR_MAX, NULL) 3159 ) 3160 ) 3161 mParent->onGuestPropertyChange (mData->mUuid, aName, aValue, aFlags); 3162 } 3163 else 3164 { 3165 ComPtr <IInternalSessionControl> directControl = 3166 mData->mSession.mDirectControl; 3167 3168 /* just be on the safe side when calling another process */ 3169 alock.leave(); 3170 3171 BSTR dummy = NULL; 3172 ULONG64 dummy64; 3173 if (!directControl) 3174 rc = E_FAIL; 3159 if ( SUCCEEDED (rc) 3160 && ( matchAll 3161 || RTStrSimplePatternMultiMatch (utf8Patterns.raw(), RTSTR_MAX, 3162 utf8Name.raw(), RTSTR_MAX, NULL) 3163 ) 3164 ) 3165 mParent->onGuestPropertyChange (mData->mUuid, aName, aValue, aFlags); 3166 } 3175 3167 else 3176 rc = directControl->AccessGuestProperty (aName, aValue, aFlags, 3177 true /* isSetter */, 3178 &dummy, &dummy64, &dummy); 3179 } 3168 { 3169 ComPtr <IInternalSessionControl> directControl = 3170 mData->mSession.mDirectControl; 3171 3172 /* just be on the safe side when calling another process */ 3173 alock.leave(); 3174 3175 BSTR dummy = NULL; 3176 ULONG64 dummy64; 3177 if (!directControl) 3178 rc = E_FAIL; 3179 else 3180 rc = directControl->AccessGuestProperty(aName, aValue, aFlags, 3181 true /* isSetter */, 3182 &dummy, &dummy64, &dummy); 3183 } 3184 } 3185 catch (std::bad_alloc &e) 3186 { 3187 rc = E_OUTOFMEMORY; 3188 } 3189 3180 3190 return rc; 3181 3191 #endif /* else !defined (VBOX_WITH_GUEST_PROPS) */ … … 5401 5411 #ifdef VBOX_WITH_GUEST_PROPS 5402 5412 /* Guest properties (optional) */ 5413 try 5403 5414 { 5404 5415 using namespace guestProp; … … 5422 5433 /* property flags (optional, defaults to empty) */ 5423 5434 Bstr flags = (*it).stringValue ("flags"); 5424 Utf8Str utf8Flags (flags); 5425 if (utf8Flags.isNull ()) 5426 return E_OUTOFMEMORY; 5435 Utf8Str utf8Flags(flags); 5427 5436 validateFlags (utf8Flags.raw(), &fFlags); 5428 5437 HWData::GuestProperty property = { name, value, timestamp, fFlags }; … … 5442 5451 if (mHWData->mGuestPropertyNotificationPatterns.isNull ()) 5443 5452 return E_OUTOFMEMORY; 5453 } 5454 catch(std::bad_alloc &e) 5455 { 5456 return E_OUTOFMEMORY; 5444 5457 } 5445 5458 #endif /* VBOX_WITH_GUEST_PROPS defined */ … … 9616 9629 return E_POINTER; /* aValue can be NULL to indicate deletion */ 9617 9630 9618 Utf8Str utf8Name (aName); 9619 Utf8Str utf8Flags (aFlags); 9620 Utf8Str utf8Patterns (mHWData->mGuestPropertyNotificationPatterns); 9621 if ( utf8Name.isNull() 9622 || ((aFlags != NULL) && utf8Flags.isNull()) 9623 || utf8Patterns.isNull() 9624 ) 9631 try 9632 { 9633 Utf8Str utf8Name(aName); 9634 Utf8Str utf8Flags(aFlags); 9635 Utf8Str utf8Patterns(mHWData->mGuestPropertyNotificationPatterns); 9636 9637 uint32_t fFlags = NILFLAG; 9638 if ((aFlags != NULL) && RT_FAILURE (validateFlags (utf8Flags.raw(), &fFlags))) 9639 return E_INVALIDARG; 9640 9641 bool matchAll = false; 9642 if (utf8Patterns.isEmpty()) 9643 matchAll = true; 9644 9645 AutoCaller autoCaller (this); 9646 CheckComRCReturnRC (autoCaller.rc()); 9647 9648 AutoWriteLock alock (this); 9649 9650 HRESULT rc = checkStateDependency (MutableStateDep); 9651 CheckComRCReturnRC (rc); 9652 9653 mHWData.backup(); 9654 for (HWData::GuestPropertyList::iterator iter = mHWData->mGuestProperties.begin(); 9655 iter != mHWData->mGuestProperties.end(); ++iter) 9656 if (aName == iter->mName) 9657 { 9658 mHWData->mGuestProperties.erase (iter); 9659 break; 9660 } 9661 if (aValue != NULL) 9662 { 9663 HWData::GuestProperty property = { aName, aValue, aTimestamp, fFlags }; 9664 mHWData->mGuestProperties.push_back (property); 9665 } 9666 9667 /* send a callback notification if appropriate */ 9668 alock.leave(); 9669 if ( matchAll 9670 || RTStrSimplePatternMultiMatch (utf8Patterns.raw(), RTSTR_MAX, 9671 utf8Name.raw(), RTSTR_MAX, NULL) 9672 ) 9673 mParent->onGuestPropertyChange (mData->mUuid, aName, aValue, aFlags); 9674 } 9675 catch(std::bad_alloc &e) 9676 { 9625 9677 return E_OUTOFMEMORY; 9626 9627 uint32_t fFlags = NILFLAG; 9628 if ((aFlags != NULL) && RT_FAILURE (validateFlags (utf8Flags.raw(), &fFlags))) 9629 return E_INVALIDARG; 9630 9631 bool matchAll = false; 9632 if (utf8Patterns.length() == 0) 9633 matchAll = true; 9634 9635 AutoCaller autoCaller (this); 9636 CheckComRCReturnRC (autoCaller.rc()); 9637 9638 AutoWriteLock alock (this); 9639 9640 HRESULT rc = checkStateDependency (MutableStateDep); 9641 CheckComRCReturnRC (rc); 9642 9643 mHWData.backup(); 9644 for (HWData::GuestPropertyList::iterator iter = mHWData->mGuestProperties.begin(); 9645 iter != mHWData->mGuestProperties.end(); ++iter) 9646 if (aName == iter->mName) 9647 { 9648 mHWData->mGuestProperties.erase (iter); 9649 break; 9650 } 9651 if (aValue != NULL) 9652 { 9653 HWData::GuestProperty property = { aName, aValue, aTimestamp, fFlags }; 9654 mHWData->mGuestProperties.push_back (property); 9655 } 9656 9657 /* send a callback notification if appropriate */ 9658 alock.leave(); 9659 if ( matchAll 9660 || RTStrSimplePatternMultiMatch (utf8Patterns.raw(), RTSTR_MAX, 9661 utf8Name.raw(), RTSTR_MAX, NULL) 9662 ) 9663 mParent->onGuestPropertyChange (mData->mUuid, aName, aValue, aFlags); 9664 9678 } 9665 9679 return S_OK; 9666 9680 #else -
trunk/src/VBox/Main/SnapshotImpl.cpp
r21394 r21404 412 412 413 413 /* state file may be NULL (for offline snapshots) */ 414 if ( !path.isEmpty()414 if ( path.length() 415 415 && RTPathStartsWith(path, aOldPath) 416 416 ) -
trunk/src/VBox/Main/VirtualBoxImpl.cpp
r21394 r21404 3481 3481 AutoReadLock hardDiskLock (aHardDisk); 3482 3482 3483 Utf8Str conflict;3484 HRESULT rc = checkMediaForConflicts2 3485 3486 conflict);3483 Utf8Str strConflict; 3484 HRESULT rc = checkMediaForConflicts2(aHardDisk->id(), 3485 aHardDisk->locationFull(), 3486 strConflict); 3487 3487 CheckComRCReturnRC (rc); 3488 3488 3489 if (!conflict.isNull()) 3490 { 3491 return setError (E_INVALIDARG, 3492 tr ("Cannot register the hard disk '%ls' with UUID {%RTuuid} " 3493 "because a %s already exists in the media registry ('%ls')"), 3494 aHardDisk->locationFull().raw(), aHardDisk->id().raw(), 3495 conflict.raw(), mData.mCfgFile.mName.raw()); 3489 if (strConflict.length()) 3490 { 3491 return setError(E_INVALIDARG, 3492 tr("Cannot register the hard disk '%ls' with UUID {%RTuuid} because a %s already exists in the media registry ('%ls')"), 3493 aHardDisk->locationFull().raw(), 3494 aHardDisk->id().raw(), 3495 strConflict.raw(), 3496 mData.mCfgFile.mName.raw()); 3496 3497 } 3497 3498 … … 3598 3599 AutoReadLock imageLock (aImage); 3599 3600 3600 Utf8Str conflict; 3601 HRESULT rc = checkMediaForConflicts2 (aImage->id(), aImage->locationFull(), 3602 conflict); 3601 Utf8Str strConflict; 3602 HRESULT rc = checkMediaForConflicts2(aImage->id(), 3603 aImage->locationFull(), 3604 strConflict); 3603 3605 CheckComRCReturnRC (rc); 3604 3606 3605 if (!conflict.isNull()) 3606 { 3607 return setError (VBOX_E_INVALID_OBJECT_STATE, 3608 tr ("Cannot register the CD/DVD image '%ls' with UUID {%RTuuid} " 3609 "because a %s already exists in the media registry ('%ls')"), 3610 aImage->locationFull().raw(), aImage->id().raw(), 3611 conflict.raw(), mData.mCfgFile.mName.raw()); 3607 if (strConflict.length()) 3608 { 3609 return setError(VBOX_E_INVALID_OBJECT_STATE, 3610 tr("Cannot register the CD/DVD image '%ls' with UUID {%RTuuid} because a %s already exists in the media registry ('%ls')"), 3611 aImage->locationFull().raw(), 3612 aImage->id().raw(), 3613 strConflict.raw(), 3614 mData.mCfgFile.mName.raw()); 3612 3615 } 3613 3616 … … 3699 3702 AutoReadLock imageLock (aImage); 3700 3703 3701 Utf8Str conflict; 3702 HRESULT rc = checkMediaForConflicts2 (aImage->id(), aImage->locationFull(), 3703 conflict); 3704 Utf8Str strConflict; 3705 HRESULT rc = checkMediaForConflicts2(aImage->id(), 3706 aImage->locationFull(), 3707 strConflict); 3704 3708 CheckComRCReturnRC (rc); 3705 3709 3706 if (!conflict.isNull()) 3707 { 3708 return setError (VBOX_E_INVALID_OBJECT_STATE, 3709 tr ("Cannot register the floppy image '%ls' with UUID {%RTuuid} " 3710 "because a %s already exists in the media registry ('%ls')"), 3711 aImage->locationFull().raw(), aImage->id().raw(), 3712 conflict.raw(), mData.mCfgFile.mName.raw()); 3710 if (strConflict.length()) 3711 { 3712 return setError(VBOX_E_INVALID_OBJECT_STATE, 3713 tr("Cannot register the floppy image '%ls' with UUID {%RTuuid} because a %s already exists in the media registry ('%ls')"), 3714 aImage->locationFull().raw(), 3715 aImage->id().raw(), 3716 strConflict.raw(), 3717 mData.mCfgFile.mName.raw()); 3713 3718 } 3714 3719 … … 3937 3942 { 3938 3943 *aFormatVersion = aTree.oldVersion(); 3939 if ( aFormatVersion->isNull())3944 if (!aFormatVersion->length()) 3940 3945 *aFormatVersion = VBOX_XML_VERSION_FULL; 3941 3946 } -
trunk/src/VBox/Main/glue/string.cpp
r21394 r21404 139 139 Utf8Str& Utf8Str::toLower() 140 140 { 141 if ( !isEmpty())141 if (length()) 142 142 ::RTStrToLower(m_psz); 143 143 return *this; … … 146 146 Utf8Str& Utf8Str::toUpper() 147 147 { 148 if ( !isEmpty())148 if (length()) 149 149 ::RTStrToUpper(m_psz); 150 150 return *this; -
trunk/src/VBox/Main/win/svchlp.cpp
r21081 r21404 179 179 180 180 /* write -1 for NULL strings */ 181 if (aVal.is Null())181 if (aVal.isEmpty()) 182 182 return write ((size_t) ~0); 183 183 -
trunk/src/VBox/Runtime/testcase/tstUtf8.cpp
r21394 r21404 987 987 988 988 copy1 = NULL; 989 CHECK( (copy1. isNull()) );989 CHECK( (copy1.length() == 0) ); 990 990 991 991 copy1 = ""; 992 CHECK( (copy1. isEmpty()) );992 CHECK( (copy1.length() == 0) ); 993 993 994 994 CHECK( (ministring("abc") < ministring("def")) );
Note:
See TracChangeset
for help on using the changeset viewer.