Handle NULL being passed to SetPrivateData/SetName

This commit is contained in:
baldurk
2018-03-07 11:26:10 +00:00
parent f03ece2128
commit e3b42b56af
4 changed files with 6 additions and 6 deletions
+1 -1
View File
@@ -182,7 +182,7 @@ template <class T>
inline void SetDebugName(T *pObj, const char *name)
{
if(pObj)
pObj->SetPrivateData(WKPDID_D3DDebugObjectName, (UINT)strlen(name), name);
pObj->SetPrivateData(WKPDID_D3DDebugObjectName, name ? (UINT)strlen(name) : 0, name);
}
template <class T>
+1 -1
View File
@@ -2224,7 +2224,7 @@ bool WrappedID3D11Device::Serialise_SetResourceName(SerialiserType &ser,
{
ResourceDescription &descr = GetReplay()->GetResourceDesc(
GetResourceManager()->GetOriginalID(GetIDForResource(pResource)));
descr.SetCustomName(Name);
descr.SetCustomName(Name ? Name : "");
AddResourceCurChunk(descr);
SetDebugName(pResource, Name);
+3 -3
View File
@@ -1945,13 +1945,13 @@ bool WrappedID3D12Device::Serialise_SetName(SerialiserType &ser, ID3D12DeviceChi
if(IsReplayingAndReading() && pResource)
{
ResourceId origId = GetResourceManager()->GetOriginalID(GetResID(pResource));
m_ResourceNames[origId] = Name;
m_ResourceNames[origId] = Name ? Name : "";
ResourceDescription &descr = GetReplay()->GetResourceDesc(origId);
descr.SetCustomName(Name);
descr.SetCustomName(Name ? Name : "");
AddResourceCurChunk(descr);
pResource->SetName(StringFormat::UTF82Wide(Name).c_str());
pResource->SetName(StringFormat::UTF82Wide(Name ? Name : "").c_str());
}
return true;
+1 -1
View File
@@ -288,7 +288,7 @@ public:
HRESULT STDMETHODCALLTYPE SetName(LPCWSTR Name)
{
string utf8 = StringFormat::Wide2UTF8(Name);
string utf8 = Name ? StringFormat::Wide2UTF8(Name) : "";
m_pDevice->SetName(this, utf8.c_str());
if(!m_pReal)