Ticket #4389 (closed: fixed)
Python handle still valid after DeleteWorkspace in MantidPlot
Reported by: | Martyn Gigg | Owned by: | Martyn Gigg |
---|---|---|---|
Priority: | major | Milestone: | Release 2.0 |
Component: | Mantid | Keywords: | |
Cc: | Blocked By: | ||
Blocking: | Tester: | Jose Borreguero |
Description
On the command line the calling DeleteWorkspace and then trying to reuse a workspace handle results in an exception being raised but the same does not happen in MantidPlot. The script below demonstrates the problem
from mantid import FrameworkManager from mantid.simpleapi import LoadRaw, DeleteWorkspace filename = '/home/dmn58364/mantidproject/test-scripts/inelastic/direct/Mantid_vs_Libisis_MAPS/RAW_files/MAP17265.raw' raw_sample = LoadRaw(Filename=filename, LoadLogFiles="0") print raw_sample.getNumberHistograms() DeleteWorkspace(raw_sample) print raw_sample.getNumberHistograms()
It should raise this error
Traceback (most recent call last): File "test-leak.py", line 9, in <module> print raw_sample.getNumberHistograms() RuntimeError: Variable invalidated, data has been deleted.
Change History
comment:2 Changed 9 years ago by Martyn Gigg
Refs #4389. Try to ensure memory is returned promptly.
Changeset: a4eef1d55c5a1b0ef1450d3f4947c089a9d5a6d8
comment:4 Changed 9 years ago by Martyn Gigg
- Status changed from accepted to verify
- Resolution set to fixed
comment:5 Changed 9 years ago by Martyn Gigg
Refs #4389. Remove a variable that causes a spurios memcheck error
Changeset: eebb1b9f4d23b619e6ed5e981f4360aeeb36b269
Note: See
TracTickets for help on using
tickets.
Refs #4389. Add a PostDeleteNotification to the DataService.
Most observers that watch for workspace deletion do not need a copy of the shared pointer. The PostDeleteNotification only has the name of what was deleted meaning the object should only be kept alive by a notification if absolutely necessary. The PreDeleteNotification does what the original DeleteNotification did.