enthought / enthought/traitsui
Cycle references left on ModelView after the UI is disposed
- Dominant language
- Python
- Stars
- 306
- Forks
- 99
- PR merge metrics
- No merged PRs in 30d
Description
In this example:
```
from traits.api import *
from traitsui.api import *
import weakref
class SomeModel(HasTraits):
number = Int()
class SomeView(ModelView):
other = Button()
view = View(Item('other'))
def _create_ephemeral():
model = SomeModel()
view = SomeView(model=model)
view.configure_traits()
return model, view
if __name__ == '__main__':
model, view = _create_ephemeral()
view_ref = weakref.ref(view)
model_ref = weakref.ref(model)
del model
del view
print(view_ref())
print(model_ref())
import gc
gc.collect()
print("After GC")
print(view_ref())
print(model_ref())
```
The output is the following:
```
<__main__.SomeView object at 0x7fbf65b24b48>
<__main__.SomeModel object at 0x7fbf65b24830>
After GC
None
None
```
Expected output is this:
```
None
None
After GC
None
None
```
This indicates cycle references being created for the ModelView (and possibly the model). Ideally these references should be cleaned up.
(Preliminary finding: Setting `view.info = None` after `configure_traits` resolves part of the issue, but not all of it.)
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.