Fixed #13843 -- Prevented AttributeError during geometry objects deletion

This commit is contained in:
Claude Paroz 2014-09-12 20:45:59 +02:00
parent b011afe6c8
commit 8f334e55be
7 changed files with 7 additions and 7 deletions

View File

@ -96,7 +96,7 @@ class DataSource(GDALBase):
def __del__(self): def __del__(self):
"Destroys this DataStructure object." "Destroys this DataStructure object."
if self._ptr: if self._ptr and capi:
capi.destroy_ds(self._ptr) capi.destroy_ds(self._ptr)
def __iter__(self): def __iter__(self):

View File

@ -34,7 +34,7 @@ class Feature(GDALBase):
def __del__(self): def __del__(self):
"Releases a reference to this object." "Releases a reference to this object."
if self._ptr: if self._ptr and capi:
capi.destroy_feature(self._ptr) capi.destroy_feature(self._ptr)
def __getitem__(self, index): def __getitem__(self, index):

View File

@ -127,7 +127,7 @@ class OGRGeometry(GDALBase):
def __del__(self): def __del__(self):
"Deletes this Geometry." "Deletes this Geometry."
if self._ptr: if self._ptr and capi:
capi.destroy_geom(self._ptr) capi.destroy_geom(self._ptr)
# Pickle routines # Pickle routines

View File

@ -97,7 +97,7 @@ class SpatialReference(GDALBase):
def __del__(self): def __del__(self):
"Destroys this spatial reference." "Destroys this spatial reference."
if self._ptr: if self._ptr and capi:
capi.release_srs(self._ptr) capi.release_srs(self._ptr)
def __getitem__(self, target): def __getitem__(self, target):

View File

@ -115,7 +115,7 @@ class GEOSGeometry(GEOSBase, ListMixin):
Destroys this Geometry; in other words, frees the memory used by the Destroys this Geometry; in other words, frees the memory used by the
GEOS C++ object. GEOS C++ object.
""" """
if self._ptr: if self._ptr and capi:
capi.destroy_geom(self._ptr) capi.destroy_geom(self._ptr)
def __copy__(self): def __copy__(self):

View File

@ -23,7 +23,7 @@ class PreparedGeometry(GEOSBase):
self.ptr = capi.geos_prepare(geom.ptr) self.ptr = capi.geos_prepare(geom.ptr)
def __del__(self): def __del__(self):
if self._ptr: if self._ptr and capi:
capi.prepared_destroy(self._ptr) capi.prepared_destroy(self._ptr)
def contains(self, other): def contains(self, other):

View File

@ -12,7 +12,7 @@ class GEOSContextHandle(object):
self.ptr = lgeos.initGEOS_r(notice_h, error_h) self.ptr = lgeos.initGEOS_r(notice_h, error_h)
def __del__(self): def __del__(self):
if self.ptr: if self.ptr and lgeos:
lgeos.finishGEOS_r(self.ptr) lgeos.finishGEOS_r(self.ptr)