View.setParent() must message all the child views with setParent(null)
when it is called with a null argument. This gives the child views a
chance to clean up before they get disconnected from the View hierarchy.
This behaviour is part of the specification of this method.
2006-02-13 Roman Kennke <[EMAIL PROTECTED]>
* javax/swing/text/AbstractDocument.java
(setParent): Added API docs. Call setParent(null) on children
before
disconnecting this view from the View hierarchy.
/Roman
Index: javax/swing/text/View.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/text/View.java,v
retrieving revision 1.27
diff -u -r1.27 View.java
--- javax/swing/text/View.java 9 Feb 2006 14:28:49 -0000 1.27
+++ javax/swing/text/View.java 13 Feb 2006 14:14:22 -0000
@@ -71,8 +71,29 @@
public abstract void paint(Graphics g, Shape s);
+ /**
+ * Sets the parent for this view. This is the first method that is beeing
+ * called on a view to setup the view hierarchy. This is also the last method
+ * beeing called when the view is disconnected from the view hierarchy, in
+ * this case <code>parent</code> is null.
+ *
+ * If <code>parent</code> is <code>null</code>, a call to this method also
+ * calls <code>setParent</code> on the children, thus disconnecting them from
+ * the view hierarchy. That means that super must be called when this method
+ * is overridden.
+ *
+ * @param parent the parent to set, <code>null</code> when this view is
+ * beeing disconnected from the view hierarchy
+ */
public void setParent(View parent)
{
+ if (parent == null)
+ {
+ int numChildren = getViewCount();
+ for (int i = 0; i < numChildren; i++)
+ getView(i).setParent(this);
+ }
+
this.parent = parent;
}