From c136c152d4d0cbc18de35eb2c4362f47920acf6f Mon Sep 17 00:00:00 2001
From: Andrew Maclean <andrew.amaclean@gmail.com>
Date: Mon, 4 May 2015 09:08:17 +1000
Subject: [PATCH] A patch from Utkarsh

This is a patch that fixes issues with
'vtk-kamino-osx-shared-release+mpi+python+tbb' builder.
---
 Common/DataModel/vtkOverlappingAMR.cxx                      | 2 +-
 Filters/Geometry/vtkStructuredAMRGridConnectivity.cxx       | 5 +++++
 Filters/Geometry/vtkStructuredGridConnectivity.h            | 6 ++++++
 Filters/ParallelGeometry/vtkPStructuredGridConnectivity.cxx | 5 +++++
 Views/Core/vtkView.cxx                                      | 2 +-
 5 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/Common/DataModel/vtkOverlappingAMR.cxx b/Common/DataModel/vtkOverlappingAMR.cxx
index 85351e0f60..459b283336 100644
--- a/Common/DataModel/vtkOverlappingAMR.cxx
+++ b/Common/DataModel/vtkOverlappingAMR.cxx
@@ -172,7 +172,7 @@ void vtkOverlappingAMR::SetOrigin(const double* origin)
 //----------------------------------------------------------------------------
 double* vtkOverlappingAMR::GetOrigin()
 {
-  return this->AMRInfo->GetOrigin();
+  return this->AMRInfo? this->AMRInfo->GetOrigin() : NULL;
 }
 
 //----------------------------------------------------------------------------
diff --git a/Filters/Geometry/vtkStructuredAMRGridConnectivity.cxx b/Filters/Geometry/vtkStructuredAMRGridConnectivity.cxx
index c5385e03e6..60cf689c3f 100644
--- a/Filters/Geometry/vtkStructuredAMRGridConnectivity.cxx
+++ b/Filters/Geometry/vtkStructuredAMRGridConnectivity.cxx
@@ -212,6 +212,11 @@ void vtkStructuredAMRGridConnectivity::Initialize(
 void vtkStructuredAMRGridConnectivity::SetNumberOfGrids(
     const unsigned int N )
 {
+  if (N == 0)
+    {
+    vtkErrorMacro("Number of grids cannot be 0.");
+    return;
+    }
   this->NumberOfGrids = N;
   this->AllocateUserRegisterDataStructures();
 
diff --git a/Filters/Geometry/vtkStructuredGridConnectivity.h b/Filters/Geometry/vtkStructuredGridConnectivity.h
index f52ec852be..ba199f58fc 100644
--- a/Filters/Geometry/vtkStructuredGridConnectivity.h
+++ b/Filters/Geometry/vtkStructuredGridConnectivity.h
@@ -973,6 +973,12 @@ inline int vtkStructuredGridConnectivity::GetNumberOfConnectingBlockFaces(
 inline void vtkStructuredGridConnectivity::SetNumberOfGrids(
     const unsigned int N )
 {
+  if (N == 0)
+    {
+    vtkErrorMacro("Number of grids cannot be 0.");
+    return;
+    }
+
   this->NumberOfGrids = N;
   this->AllocateUserRegisterDataStructures();
 
diff --git a/Filters/ParallelGeometry/vtkPStructuredGridConnectivity.cxx b/Filters/ParallelGeometry/vtkPStructuredGridConnectivity.cxx
index 81376b8503..1ad94f063e 100644
--- a/Filters/ParallelGeometry/vtkPStructuredGridConnectivity.cxx
+++ b/Filters/ParallelGeometry/vtkPStructuredGridConnectivity.cxx
@@ -71,6 +71,11 @@ void vtkPStructuredGridConnectivity::Initialize()
 //------------------------------------------------------------------------------
 void vtkPStructuredGridConnectivity::SetNumberOfGrids( const unsigned int N )
 {
+  if (N == 0)
+    {
+    vtkErrorMacro("Number of grids cannot be 0.");
+    return;
+    }
   this->Superclass::SetNumberOfGrids( N );
   this->GridRanks.resize( N,-1 );
 }
diff --git a/Views/Core/vtkView.cxx b/Views/Core/vtkView.cxx
index 4b532b8a6d..eae55d3797 100644
--- a/Views/Core/vtkView.cxx
+++ b/Views/Core/vtkView.cxx
@@ -184,7 +184,7 @@ vtkDataRepresentation* vtkView::SetRepresentationFromInputConnection(vtkAlgorith
 //----------------------------------------------------------------------------
 void vtkView::AddRepresentation(vtkDataRepresentation* rep)
 {
-  if (!this->IsRepresentationPresent(rep))
+  if (rep != NULL && !this->IsRepresentationPresent(rep))
     {
     if (rep->AddToView(this))
       {
-- 
GitLab