Browse Source

Merge pull request #1378 from Areloch/PVS_Cleanup_595

Properly testing pointer vars aren't null before using them.
Areloch 10 years ago
parent
commit
b54f41e36d

+ 1 - 1
Engine/source/T3D/convexShape.cpp

@@ -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 

+ 1 - 1
Engine/source/T3D/examples/renderMeshExample.cpp

@@ -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 

+ 2 - 1
Engine/source/console/consoleObject.cpp

@@ -847,12 +847,13 @@ 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
    
    

+ 1 - 1
Engine/source/gfx/D3D9/pc/gfxPCD3D9Device.cpp

@@ -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));
       }
       }
 
 

+ 1 - 1
Engine/source/gui/containers/guiWindowCtrl.cpp

@@ -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

+ 32 - 25
Engine/source/gui/core/guiControl.cpp

@@ -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() )
+   
+   if (bCanSave && mAddGroup)
    {
    {
-      MutexHandle handle;
-      handle.lock(mMutex);
+      StringTableEntry steName = mAddGroup->getInternalName();
 
 
-      // export selected only?
-      if((flags & SelectedOnly) && !isSelected())
+      if ((steName != NULL) && (steName != StringTable->insert("null")) && getName())
       {
       {
-         for(U32 i = 0; i < size(); i++)
-            (*this)[i]->write(stream, tabStop, flags);
+         MutexHandle handle;
+         handle.lock(mMutex);
 
 
-         return;
+         // 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);
+         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);
 
 
-      stream.writeTabs(tabStop);
-      stream.write(4, "};\r\n");
+         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;
+      }
    }
    }
-   else if (bCanSave)
+   
+   if (bCanSave)
       Parent::write( stream, tabStop, flags );
       Parent::write( stream, tabStop, flags );
-
 }
 }
 
 
 //=============================================================================
 //=============================================================================

+ 1 - 1
Engine/source/gui/worldEditor/worldEditor.cpp

@@ -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);
 
 

+ 1 - 1
Engine/source/postFx/postEffect.cpp

@@ -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 );

+ 13 - 14
Engine/source/renderInstance/renderPrePassMgr.cpp

@@ -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 ( isDecalMeshInst && !matInst->hasNormalMap() )
-      return;
+   if (matInst)
+   {
+      // Skip decals if they don't have normal maps.
+      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;
+      // 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.
-   if ( matInst )
-   {
-      matInst = getPrePassMaterial( matInst );
-      if ( !matInst || !matInst->isValid() )
+      // 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;