wx.RefCounter¶
This class is used to manage reference-counting providing a simple interface and a counter.
wx.RefCounter can be easily used together with wx.ObjectDataPtr to ensure that no calls to wx.RefCounter.DecRef
are missed - thus avoiding memory leaks.
wx.ObjectRefData is a typedef to wx.RefCounter and is used as the built-in reference counted storage for Object-derived classes.
See also
wx.Object, wx.ObjectRefData , wx.ObjectDataPtr , Reference Counting
Class Hierarchy¶
Known Subclasses¶
wx.BitmapBundleImpl, wx.dataview.DataViewModel, wx.grid.GridCellAttr, wx.grid.GridCellEditor, wx.grid.GridCellRenderer
Methods Summary¶
Default constructor. |
|
Decrements the reference count associated with this shared data and, if it reaches zero, destroys this instance of wx.RefCounter releasing its memory. |
|
Returns the reference count associated with this shared data. |
|
Increments the reference count associated with this shared data. |
|
|
Destructor. |
Properties Summary¶
See |
Class API¶
- class wx.RefCounter(object)¶
Possible constructors:
RefCounter() -> None
This class is used to manage reference-counting providing a simple interface and a counter.
Methods¶
- __init__(self)¶
Default constructor.
Initialises the internal reference count to 1.
- Return type:
None
- DecRef(self)¶
Decrements the reference count associated with this shared data and, if it reaches zero, destroys this instance of wx.RefCounter releasing its memory.
Please note that after calling this function, the caller should absolutely avoid to use the pointer to this instance since it may not be valid anymore.
- Return type:
None
- GetRefCount(self)¶
Returns the reference count associated with this shared data.
When this goes to zero during a
DecRef
call, the object will auto-free itself.- Return type:
int
- IncRef(self)¶
Increments the reference count associated with this shared data.
- Return type:
None
- ~wxRefCounter(self)
Destructor.
It’s declared
protected
so that wx.RefCounter instances will never be destroyed directly but only as result of aDecRef
call.- Return type:
None
Properties¶
- RefCount¶
See
GetRefCount