Commit a3b18a2
committed
BUG : fixes FontProperties memory leak
According to the data
model (https://docs.python.org/2/reference/datamodel.html#object.__hash__)
objects that define __hash__ need to define __eq__ or __cmp__. By
default, all user defined classes have a __cmp__ which evaluates to
False for all other objects.
Previously we do not define either __cmp__ or __eq__ on FontProperties,
This results in never finding the property
cached in the dict, hence the growth in the number of
FontProperties (and I assume the stuff in them).
By adding __eq__ and __ne__ we complete the data model and adding
FontProperties to dictionaries should work as expected.
This was not a problem before, but in #3077 the caching key was changed
from hash(prop) -> prop.
Closes #32641 parent 71dc35a commit a3b18a2
1 file changed
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
707 | 707 | | |
708 | 708 | | |
709 | 709 | | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
710 | 716 | | |
711 | 717 | | |
712 | 718 | | |
| |||
0 commit comments