Commit b4c4b77c authored by Dan Lipsa's avatar Dan Lipsa Committed by Kitware Robot
Browse files

Merge topic 'macos_crash'

4b37fcd4 BUG: push_back may cause pointers to become invalid
d3313b1b

 BUG #1777: lambert test creates mangled up image
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !1249
parents 392555e8 4b37fcd4
...@@ -104,10 +104,11 @@ const char* vtkGeoProjection::GetProjectionDescription( int projection ) ...@@ -104,10 +104,11 @@ const char* vtkGeoProjection::GetProjectionDescription( int projection )
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
vtkGeoProjection::vtkGeoProjection() vtkGeoProjection::vtkGeoProjection()
{ {
this->Name = 0; this->Name = NULL;
this->SetName( "latlong" ); this->SetName( "latlong" );
this->CentralMeridian = 0.; this->CentralMeridian = 0.;
this->Projection = 0; this->Projection = NULL;
this->ProjectionMTime = 0;
this->Internals = new vtkInternals(); this->Internals = new vtkInternals();
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
...@@ -138,9 +139,6 @@ void vtkGeoProjection::PrintSelf( ostream& os, vtkIndent indent ) ...@@ -138,9 +139,6 @@ void vtkGeoProjection::PrintSelf( ostream& os, vtkIndent indent )
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
int vtkGeoProjection::GetIndex() int vtkGeoProjection::GetIndex()
{ {
this->UpdateProjection();
if ( ! this->Projection )
return -1;
int i = 0; int i = 0;
for ( const PJ_LIST* proj = pj_get_list_ref(); proj && proj->id; ++ proj, ++ i ) for ( const PJ_LIST* proj = pj_get_list_ref(); proj && proj->id; ++ proj, ++ i )
{ {
...@@ -190,7 +188,7 @@ int vtkGeoProjection::UpdateProjection() ...@@ -190,7 +188,7 @@ int vtkGeoProjection::UpdateProjection()
if ( ! strcmp ( this->Name, "latlong" ) ) if ( ! strcmp ( this->Name, "latlong" ) )
{ {
// latlong is "null" projection. // latlong is "null" projection.
return 1; return 0;
} }
int argSize = 3 + this->GetNumberOfOptionalParameters(); int argSize = 3 + this->GetNumberOfOptionalParameters();
...@@ -207,23 +205,25 @@ int vtkGeoProjection::UpdateProjection() ...@@ -207,23 +205,25 @@ int vtkGeoProjection::UpdateProjection()
pjArgs[2] = meridSpec.c_str(); pjArgs[2] = meridSpec.c_str();
// Add optional parameters // Add optional parameters
std::vector<std::string> stringHolder; // Keep string ref in memory std::vector<std::string> stringHolder(
this->GetNumberOfOptionalParameters()); // Keep string ref in memory
for(int i=0; i < this->GetNumberOfOptionalParameters(); i++) for(int i=0; i < this->GetNumberOfOptionalParameters(); i++)
{ {
std::ostringstream param; std::ostringstream param;
param << "+" << this->GetOptionalParameterKey(i); param << "+" << this->GetOptionalParameterKey(i);
param << "=" << this->GetOptionalParameterValue(i); param << "=" << this->GetOptionalParameterValue(i);
stringHolder.push_back(param.str()); stringHolder[i] = param.str();
pjArgs[3+i] = stringHolder[i].c_str(); pjArgs[3+i] = stringHolder[i].c_str();
} }
this->Projection = pj_init( argSize, const_cast<char**>( pjArgs ) ); this->Projection = pj_init( argSize, const_cast<char**>( pjArgs ) );
delete[] pjArgs; delete[] pjArgs;
this->ProjectionMTime = this->GetMTime();
if ( this->Projection ) if ( this->Projection )
{ {
return 1; return 0;
} }
return 0; return 1;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
...@@ -232,18 +232,19 @@ void vtkGeoProjection::SetOptionalParameter(const char* key, const char* value) ...@@ -232,18 +232,19 @@ void vtkGeoProjection::SetOptionalParameter(const char* key, const char* value)
if(key != NULL && value != NULL) if(key != NULL && value != NULL)
{ {
this->Internals->OptionalParameters[key] = value; this->Internals->OptionalParameters[key] = value;
this->Modified();
} }
else else
{ {
vtkErrorMacro("Invalid Optional Parameter Key/Value pair. None can be NULL"); vtkErrorMacro("Invalid Optional Parameter Key/Value pair. None can be NULL");
} }
this->UpdateProjection();
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void vtkGeoProjection::RemoveOptionalParameter(const char* key) void vtkGeoProjection::RemoveOptionalParameter(const char* key)
{ {
this->Internals->OptionalParameters.erase(key); this->Internals->OptionalParameters.erase(key);
this->UpdateProjection(); this->Modified();
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
int vtkGeoProjection::GetNumberOfOptionalParameters() int vtkGeoProjection::GetNumberOfOptionalParameters()
...@@ -264,5 +265,5 @@ const char* vtkGeoProjection::GetOptionalParameterValue(int index) ...@@ -264,5 +265,5 @@ const char* vtkGeoProjection::GetOptionalParameterValue(int index)
void vtkGeoProjection::ClearOptionalParameters() void vtkGeoProjection::ClearOptionalParameters()
{ {
this->Internals->OptionalParameters.clear(); this->Internals->OptionalParameters.clear();
this->UpdateProjection(); this->Modified();
} }
...@@ -127,7 +127,7 @@ protected: ...@@ -127,7 +127,7 @@ protected:
char* Name; char* Name;
double CentralMeridian; double CentralMeridian;
projPJ Projection; projPJ Projection;
vtkTimeStamp ProjectionMTime; unsigned long ProjectionMTime;
private: private:
vtkGeoProjection( const vtkGeoProjection& ); // Not implemented. vtkGeoProjection( const vtkGeoProjection& ); // Not implemented.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment