Merge pull request #1378 from Areloch/PVS_Cleanup_595

Properly testing pointer vars aren't null before using them.
This commit is contained in:
Areloch 2015-08-22 23:17:43 -05:00
commit b54f41e36d
9 changed files with 56 additions and 49 deletions

View file

@ -502,7 +502,7 @@ void ConvexShape::prepRenderImage( SceneRenderState *state )
} }
*/ */
if ( mVertexBuffer.isNull() ) if ( mVertexBuffer.isNull() || !state)
return; return;
// If we don't have a material instance after the override then // If we don't have a material instance after the override then

View file

@ -269,7 +269,7 @@ void RenderMeshExample::prepRenderImage( SceneRenderState *state )
createGeometry(); createGeometry();
// If we have no material then skip out. // If we have no material then skip out.
if ( !mMaterialInst ) if ( !mMaterialInst || !state)
return; return;
// If we don't have a material instance after the override then // If we don't have a material instance after the override then

View file

@ -847,13 +847,14 @@ DefineEngineFunction(linkNamespaces, bool, ( String childNSName, String parentNS
Namespace *childNS = Namespace::find(childNSSTE); Namespace *childNS = Namespace::find(childNSSTE);
Namespace *parentNS = Namespace::find(parentNSSTE); Namespace *parentNS = Namespace::find(parentNSSTE);
Namespace *currentParent = childNS->getParent();
if (!childNS) if (!childNS)
{ {
return false; return false;
} }
Namespace *currentParent = childNS->getParent();
// Link to new NS if applicable // Link to new NS if applicable
if (currentParent != parentNS) if (currentParent != parentNS)

View file

@ -66,7 +66,7 @@ void GFXPCD3D9Device::createDirect3D9(LPDIRECT3D9 &d3d9, LPDIRECT3D9EX &d3d9ex)
if (pfnCreate9Ex) if (pfnCreate9Ex)
{ {
if (!FAILED(pfnCreate9Ex(D3D_SDK_VERSION, &d3d9ex)) && d3d9ex) if (d3d9ex && !FAILED(pfnCreate9Ex(D3D_SDK_VERSION, &d3d9ex)))
d3d9ex->QueryInterface(__uuidof(IDirect3D9), reinterpret_cast<void **>(&d3d9)); d3d9ex->QueryInterface(__uuidof(IDirect3D9), reinterpret_cast<void **>(&d3d9));
} }

View file

@ -1212,7 +1212,7 @@ void GuiWindowCtrl::onMouseUp(const GuiEvent &event)
// We're either moving out of a collapse group or moving to another one // We're either moving out of a collapse group or moving to another one
// Not valid for windows not previously in a group // Not valid for windows not previously in a group
if( mCollapseGroup >= 0 && if( mCollapseGroup >= 0 &&
( snapType == -1 || ( snapType >= 0 && mCollapseGroup != hitWindow->mCollapseGroup) ) ) (snapType == -1 || (hitWindow && snapType >= 0 && mCollapseGroup != hitWindow->mCollapseGroup)))
moveFromCollapseGroup(); moveFromCollapseGroup();
// No window to connect to // No window to connect to

View file

@ -1755,41 +1755,48 @@ void GuiControl::write(Stream &stream, U32 tabStop, U32 flags)
{ {
//note: this will return false if either we, or any of our parents, are non-save controls //note: this will return false if either we, or any of our parents, are non-save controls
bool bCanSave = ( flags & IgnoreCanSave ) || ( flags & NoCheckParentCanSave && getCanSave() ) || getCanSaveParent(); bool bCanSave = ( flags & IgnoreCanSave ) || ( flags & NoCheckParentCanSave && getCanSave() ) || getCanSaveParent();
StringTableEntry steName = mAddGroup->getInternalName();
if(bCanSave && mAddGroup && (steName != NULL) && (steName != StringTable->insert("null")) && getName() )
{
MutexHandle handle;
handle.lock(mMutex);
// export selected only? if (bCanSave && mAddGroup)
if((flags & SelectedOnly) && !isSelected()) {
StringTableEntry steName = mAddGroup->getInternalName();
if ((steName != NULL) && (steName != StringTable->insert("null")) && getName())
{ {
for(U32 i = 0; i < size(); i++) MutexHandle handle;
(*this)[i]->write(stream, tabStop, flags); handle.lock(mMutex);
// export selected only?
if ((flags & SelectedOnly) && !isSelected())
{
for (U32 i = 0; i < size(); i++)
(*this)[i]->write(stream, tabStop, flags);
return;
}
stream.writeTabs(tabStop);
char buffer[1024];
dSprintf(buffer, sizeof(buffer), "new %s(%s,%s) {\r\n", getClassName(), getName() ? getName() : "", mAddGroup->getInternalName());
stream.write(dStrlen(buffer), buffer);
writeFields(stream, tabStop + 1);
if (size())
{
stream.write(2, "\r\n");
for (U32 i = 0; i < size(); i++)
(*this)[i]->write(stream, tabStop + 1, flags);
}
stream.writeTabs(tabStop);
stream.write(4, "};\r\n");
return; return;
} }
stream.writeTabs(tabStop);
char buffer[1024];
dSprintf(buffer, sizeof(buffer), "new %s(%s,%s) {\r\n", getClassName(), getName() ? getName() : "", mAddGroup->getInternalName());
stream.write(dStrlen(buffer), buffer);
writeFields(stream, tabStop + 1);
if(size())
{
stream.write(2, "\r\n");
for(U32 i = 0; i < size(); i++)
(*this)[i]->write(stream, tabStop + 1, flags);
}
stream.writeTabs(tabStop);
stream.write(4, "};\r\n");
} }
else if (bCanSave)
Parent::write( stream, tabStop, flags );
if (bCanSave)
Parent::write( stream, tabStop, flags );
} }
//============================================================================= //=============================================================================

View file

@ -2655,7 +2655,7 @@ void WorldEditor::renderScene( const RectI &updateRect )
// Probably should test the entire icon screen-rect instead of just the centerpoint // Probably should test the entire icon screen-rect instead of just the centerpoint
// but would need to move some code from renderScreenObj to here. // but would need to move some code from renderScreenObj to here.
if ( mDragSelect ) if (mDragSelect && selection)
if ( mDragRect.pointInRect(sPosI) && !selection->objInSet(obj) ) if ( mDragRect.pointInRect(sPosI) && !selection->objInSet(obj) )
mDragSelected->addObject(obj); mDragSelected->addObject(obj);

View file

@ -737,7 +737,7 @@ void PostEffect::_setupConstants( const SceneRenderState *state )
mShaderConsts->set( mMatPrevScreenToWorldSC, tempMat ); mShaderConsts->set( mMatPrevScreenToWorldSC, tempMat );
} }
if ( mAmbientColorSC->isValid() ) if (mAmbientColorSC->isValid() && state)
{ {
const ColorF &sunlight = state->getAmbientLightColor(); const ColorF &sunlight = state->getAmbientLightColor();
Point3F ambientColor( sunlight.red, sunlight.green, sunlight.blue ); Point3F ambientColor( sunlight.red, sunlight.green, sunlight.blue );

View file

@ -202,21 +202,20 @@ void RenderPrePassMgr::addElement( RenderInst *inst )
if ( isMeshInst || isDecalMeshInst ) if ( isMeshInst || isDecalMeshInst )
matInst = static_cast<MeshRenderInst*>(inst)->matInst; matInst = static_cast<MeshRenderInst*>(inst)->matInst;
// Skip decals if they don't have normal maps. if (matInst)
if ( isDecalMeshInst && !matInst->hasNormalMap() )
return;
// If its a custom material and it refracts... skip it.
if ( matInst &&
matInst->isCustomMaterial() &&
static_cast<CustomMaterial*>( matInst->getMaterial() )->mRefract )
return;
// Make sure we got a prepass material.
if ( matInst )
{ {
matInst = getPrePassMaterial( matInst ); // Skip decals if they don't have normal maps.
if ( !matInst || !matInst->isValid() ) if (isDecalMeshInst && !matInst->hasNormalMap())
return;
// If its a custom material and it refracts... skip it.
if (matInst->isCustomMaterial() &&
static_cast<CustomMaterial*>(matInst->getMaterial())->mRefract)
return;
// Make sure we got a prepass material.
matInst = getPrePassMaterial(matInst);
if (!matInst || !matInst->isValid())
return; return;
} }
@ -241,7 +240,7 @@ void RenderPrePassMgr::addElement( RenderInst *inst )
elem.key = *((U32*)&invSortDistSq); elem.key = *((U32*)&invSortDistSq);
// Next sort by pre-pass material if its a mesh... use the original sort key. // Next sort by pre-pass material if its a mesh... use the original sort key.
if ( isMeshInst ) if (isMeshInst && matInst)
elem.key2 = matInst->getStateHint(); elem.key2 = matInst->getStateHint();
else else
elem.key2 = originalKey; elem.key2 = originalKey;