242 |
self.session.Destroy() |
self.session.Destroy() |
243 |
self.session = None |
self.session = None |
244 |
|
|
245 |
|
def test_leak(self): |
246 |
|
"""Test load_session for resource leaks |
247 |
|
|
248 |
|
The load_session function had a resource leak in that it created |
249 |
|
cyclic references. The objects would have been eventually |
250 |
|
collected by the garbage collector but too late. One symptom is |
251 |
|
that when layers are removed so that the last normal reference |
252 |
|
owned indirectly by the session to a shape store goes away, the |
253 |
|
shape store is not actually removed from the session even though |
254 |
|
the session only keeps weak references because there are still |
255 |
|
references owned by the cyclic garbage. |
256 |
|
""" |
257 |
|
session = load_session(self.filename()) |
258 |
|
self.session = session |
259 |
|
|
260 |
|
# sanity check |
261 |
|
self.assertEquals(len(session.ShapeStores()), 1) |
262 |
|
|
263 |
|
# remove the map. The shapestore should go away too |
264 |
|
session.RemoveMap(session.Maps()[0]) |
265 |
|
self.assertEquals(len(session.ShapeStores()), 0) |
266 |
|
|
267 |
|
|
268 |
class TestLayerVisibility(LoadSessionTest): |
class TestLayerVisibility(LoadSessionTest): |
269 |
|
|