diff --git a/src/gis/tmeditmanager.cpp b/src/gis/tmeditmanager.cpp index a641c8f8..c42b311f 100644 --- a/src/gis/tmeditmanager.cpp +++ b/src/gis/tmeditmanager.cpp @@ -2306,6 +2306,9 @@ bool tmEditManager::FlipLine() { for (unsigned int f = 0; f < mySelected->GetCount(); f++) { OGRFeature* myFeature = mySelLayer->GetFeatureByOID(mySelected->Item(f)); wxASSERT(myFeature); + if (myFeature == nullptr) { + continue; + } // don't delete, internally geometry. OGRLineString* myOGRSelLine = (OGRLineString*)myFeature->GetGeometryRef(); diff --git a/src/gis/tmgisdatavector.cpp b/src/gis/tmgisdatavector.cpp index e0437634..846df053 100644 --- a/src/gis/tmgisdatavector.cpp +++ b/src/gis/tmgisdatavector.cpp @@ -453,7 +453,9 @@ OGRGeometry* tmGISDataVector::CreateOGRGeometry(const wxRealPoint& pt) { bool tmGISDataVector::CutLineAtVertex(long oid, const wxRealPoint& clickedpt, int searchRadius, int layertype) { // get the line OGRFeature* myFeature = GetFeatureByOID(oid); - wxASSERT(myFeature); + if (myFeature == nullptr) { + return false; + } OGRLineString* myLine = (OGRLineString*)myFeature->GetGeometryRef(); // create search buffer diff --git a/src/gis/tmimport.cpp b/src/gis/tmimport.cpp index 1bb65154..532080ed 100644 --- a/src/gis/tmimport.cpp +++ b/src/gis/tmimport.cpp @@ -228,6 +228,7 @@ bool tmImport::SetAttributes(DataBaseTM* database, PrjDefMemManage* prj, const w wxArrayLong& oids) { // Get layer ProjectDefMemoryLayers* layer = prj->FindLayer(m_LayerName); + if (layer == nullptr) return false; // Get field names wxArrayString fields; diff --git a/src/gis/tmimportgis.cpp b/src/gis/tmimportgis.cpp index 8674de0b..814325ba 100644 --- a/src/gis/tmimportgis.cpp +++ b/src/gis/tmimportgis.cpp @@ -87,6 +87,11 @@ bool tmImportGIS::Import(DataBaseTM* database, PrjDefMemManage* prj, wxProgressD } OGRGeometry* myGeom = myFeature->GetGeometryRef(); + if (myGeom == nullptr) { + OGRFeature::DestroyFeature(myFeature); + wxLogWarning(_("Empty geometry in feature %ld"), myFeature->GetFID()); + continue; + } wxASSERT(myGeom); wxArrayLong oids; diff --git a/src/gis/tmlayermanager.cpp b/src/gis/tmlayermanager.cpp index 8aaa340b..375dc944 100644 --- a/src/gis/tmlayermanager.cpp +++ b/src/gis/tmlayermanager.cpp @@ -607,7 +607,11 @@ bool tmLayerManager::_ReplaceLayer(const wxFileName& filename, const wxString& o // need to create an attribut index ? if (myLayerToReplace->GetSymbolRuleManagerRef()->GetRulesRef()->GetCount() > 0 && myLayerToReplace->GetSymbolRuleManagerRef()->IsUsingRules()) { - tmGISDataVectorSHP* myGISData = (tmGISDataVectorSHP*)tmGISData::LoadLayer(myLayerToReplace); + auto myGISData = (tmGISDataVectorSHP*)tmGISData::LoadLayer(myLayerToReplace); + if (myGISData == nullptr) { + wxLogError(_("Unable to load layer : %s"), myLayerToReplace->GetName().GetName()); + return false; + } wxString myQuery2 = wxString::Format(_T("DROP INDEX on %s"), myLayerToReplace->GetName().GetName()); myGISData->ExecuteSQLQuery(myQuery2); wxString myFieldName = myLayerToReplace->GetSymbolRuleManagerRef()->GetFieldName();