The javadoc of SWT CTabItem.dispose() mentioned that:
This method is not called recursively on the descendants of the receiver
What is the reason behind that? If the CTabItem is disposed, the child widgets are not displayed anymore. Why they are not disposed recursively?
Would there be any problem if I override the CTabItem.dispose() method to dispose the child widgets recursively?
Thanks
That comment is actually in the JavaDoc for the
Widget
class whichCTabItem
is derived from, it applies to all controls.When you call
dispose
the children of the control are destroyed, but not by calling the child controlsdispose
method.The JavaDoc is telling you that overriding the
dispose
method won't work if you want to know when the control is disposed, instead you must listen for theSWT.Disposed
event.The code for
Widget.dispose
is:and
release
:So it is the
release
method that callsreleaseChildren
to destroy the children.releaseChildren
for theComposite
control is:So this calls
release
on the child control (notdispose
)