Container.java (validate): Use tree lock.
* java/awt/Container.java (validate): Use tree lock. (getComponent): Likewise. (getComponents): Likewise. (addImpl): Likewise. (remove): Likewise. (removeAll): Likewise. (processEvent): Fixed indentation. (getComponentAt): Use tree lock. (findComponentAt): Likewise. (removeNotify): Likewise. (isAncestorOf): Likewise. (list): Likewise. (visitChildren): Likewise. (findNextFocusComponent): Likewise. (addNotifyContainerChildren): Likewise. (getAccessibleChildrenCount): Likewise. (getAccessibleChild): Likewise. From-SVN: r59009
This commit is contained in:
parent
f981a754fc
commit
459c4c517e
2 changed files with 275 additions and 208 deletions
|
@ -1,5 +1,23 @@
|
|||
2002-11-10 Tom Tromey <tromey@redhat.com>
|
||||
|
||||
* java/awt/Container.java (validate): Use tree lock.
|
||||
(getComponent): Likewise.
|
||||
(getComponents): Likewise.
|
||||
(addImpl): Likewise.
|
||||
(remove): Likewise.
|
||||
(removeAll): Likewise.
|
||||
(processEvent): Fixed indentation.
|
||||
(getComponentAt): Use tree lock.
|
||||
(findComponentAt): Likewise.
|
||||
(removeNotify): Likewise.
|
||||
(isAncestorOf): Likewise.
|
||||
(list): Likewise.
|
||||
(visitChildren): Likewise.
|
||||
(findNextFocusComponent): Likewise.
|
||||
(addNotifyContainerChildren): Likewise.
|
||||
(getAccessibleChildrenCount): Likewise.
|
||||
(getAccessibleChild): Likewise.
|
||||
|
||||
* java/awt/GridLayout.java (layoutContainer): Use tree lock.
|
||||
(getSize): Likewise.
|
||||
* java/awt/FlowLayout.java (layoutContainer): Use tree lock.
|
||||
|
|
|
@ -122,11 +122,14 @@ public class Container extends Component
|
|||
* @throws ArrayIndexOutOfBoundsException If the specified index is invalid
|
||||
*/
|
||||
public Component getComponent(int n)
|
||||
{
|
||||
synchronized (getTreeLock ())
|
||||
{
|
||||
if (n < 0 || n >= ncomponents)
|
||||
throw new ArrayIndexOutOfBoundsException("no such component");
|
||||
return component[n];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of the components in this container.
|
||||
|
@ -134,12 +137,15 @@ public class Container extends Component
|
|||
* @return The components in this container.
|
||||
*/
|
||||
public Component[] getComponents()
|
||||
{
|
||||
synchronized (getTreeLock ())
|
||||
{
|
||||
Component[] result = new Component[ncomponents];
|
||||
if (ncomponents > 0)
|
||||
System.arraycopy(component, 0, result, 0, ncomponents);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the insets for this container, which is the space used for
|
||||
|
@ -259,6 +265,8 @@ public class Container extends Component
|
|||
* @throws ArrayIndexOutOfBounds If the specified index is invalid.
|
||||
*/
|
||||
protected void addImpl(Component comp, Object constraints, int index)
|
||||
{
|
||||
synchronized (getTreeLock ())
|
||||
{
|
||||
if (index > ncomponents
|
||||
|| (index < 0 && index != -1)
|
||||
|
@ -324,6 +332,7 @@ public class Container extends Component
|
|||
comp);
|
||||
getToolkit().getSystemEventQueue().postEvent(ce);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the component at the specified index from this container.
|
||||
|
@ -331,6 +340,8 @@ public class Container extends Component
|
|||
* @param index The index of the component to remove.
|
||||
*/
|
||||
public void remove(int index)
|
||||
{
|
||||
synchronized (getTreeLock ())
|
||||
{
|
||||
Component r = component[index];
|
||||
|
||||
|
@ -351,6 +362,7 @@ public class Container extends Component
|
|||
r);
|
||||
getToolkit().getSystemEventQueue().postEvent(ce);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the specified component from this container.
|
||||
|
@ -358,6 +370,8 @@ public class Container extends Component
|
|||
* @return component The component to remove from this container.
|
||||
*/
|
||||
public void remove(Component comp)
|
||||
{
|
||||
synchronized (getTreeLock ())
|
||||
{
|
||||
for (int i = 0; i < ncomponents; ++i)
|
||||
{
|
||||
|
@ -368,15 +382,19 @@ public class Container extends Component
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all components from this container.
|
||||
*/
|
||||
public void removeAll()
|
||||
{
|
||||
synchronized (getTreeLock ())
|
||||
{
|
||||
while (ncomponents > 0)
|
||||
remove(0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current layout manager for this container.
|
||||
|
@ -433,8 +451,7 @@ public class Container extends Component
|
|||
*/
|
||||
public void validate()
|
||||
{
|
||||
// FIXME: use the tree lock?
|
||||
synchronized (this)
|
||||
synchronized (getTreeLock ())
|
||||
{
|
||||
if (! isValid())
|
||||
{
|
||||
|
@ -713,7 +730,8 @@ public class Container extends Component
|
|||
{
|
||||
if (e instanceof ContainerEvent)
|
||||
processContainerEvent((ContainerEvent) e);
|
||||
else super.processEvent(e);
|
||||
else
|
||||
super.processEvent(e);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -763,6 +781,8 @@ public class Container extends Component
|
|||
* <code>null</code> if there is no such point.
|
||||
*/
|
||||
public Component getComponentAt(int x, int y)
|
||||
{
|
||||
synchronized (getTreeLock ())
|
||||
{
|
||||
if (! contains(x, y))
|
||||
return null;
|
||||
|
@ -779,6 +799,7 @@ public class Container extends Component
|
|||
}
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the component located at the specified point. This is done
|
||||
|
@ -817,6 +838,8 @@ public class Container extends Component
|
|||
}
|
||||
|
||||
public Component findComponentAt(int x, int y)
|
||||
{
|
||||
synchronized (getTreeLock ())
|
||||
{
|
||||
if (! contains(x, y))
|
||||
return null;
|
||||
|
@ -844,6 +867,7 @@ public class Container extends Component
|
|||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public Component findComponentAt(Point p)
|
||||
{
|
||||
|
@ -867,11 +891,14 @@ public class Container extends Component
|
|||
* component to be destroyed as well.
|
||||
*/
|
||||
public void removeNotify()
|
||||
{
|
||||
synchronized (getTreeLock ())
|
||||
{
|
||||
for (int i = 0; i < ncomponents; ++i)
|
||||
component[i].removeNotify();
|
||||
super.removeNotify();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests whether or not the specified component is contained within
|
||||
|
@ -880,9 +907,11 @@ public class Container extends Component
|
|||
* @param component The component to test.
|
||||
*
|
||||
* @return <code>true</code> if this container is an ancestor of the
|
||||
* specified component, <code>false</code>.
|
||||
* specified component, <code>false</code> otherwise.
|
||||
*/
|
||||
public boolean isAncestorOf(Component comp)
|
||||
{
|
||||
synchronized (getTreeLock ())
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
|
@ -893,6 +922,7 @@ public class Container extends Component
|
|||
comp = comp.getParent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representing the state of this container for
|
||||
|
@ -917,11 +947,14 @@ public class Container extends Component
|
|||
* @param indent The indentation point.
|
||||
*/
|
||||
public void list(PrintStream out, int indent)
|
||||
{
|
||||
synchronized (getTreeLock ())
|
||||
{
|
||||
super.list(out, indent);
|
||||
for (int i = 0; i < ncomponents; ++i)
|
||||
component[i].list(out, indent + 2);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a listing of this container to the specified stream starting
|
||||
|
@ -931,11 +964,14 @@ public class Container extends Component
|
|||
* @param indent The indentation point.
|
||||
*/
|
||||
public void list(PrintWriter out, int indent)
|
||||
{
|
||||
synchronized (getTreeLock ())
|
||||
{
|
||||
super.list(out, indent);
|
||||
for (int i = 0; i < ncomponents; ++i)
|
||||
component[i].list(out, indent + 2);
|
||||
}
|
||||
}
|
||||
|
||||
public void setFocusTraversalKeys(int id, Set keys)
|
||||
{
|
||||
|
@ -1006,8 +1042,8 @@ public class Container extends Component
|
|||
private void visitChildren(Graphics gfx, GfxVisitor visitor,
|
||||
boolean lightweightOnly)
|
||||
{
|
||||
// FIXME: do locking
|
||||
|
||||
synchronized (getTreeLock ())
|
||||
{
|
||||
for (int i = 0; i < ncomponents; ++i)
|
||||
{
|
||||
Component comp = component[i];
|
||||
|
@ -1018,6 +1054,7 @@ public class Container extends Component
|
|||
visitChild(gfx, visitor, comp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform a graphics operation on a child. A translated and clipped
|
||||
|
@ -1060,6 +1097,8 @@ public class Container extends Component
|
|||
|
||||
// This is used to implement Component.transferFocus.
|
||||
Component findNextFocusComponent(Component child)
|
||||
{
|
||||
synchronized (getTreeLock ())
|
||||
{
|
||||
int start, end;
|
||||
if (child != null)
|
||||
|
@ -1106,8 +1145,11 @@ public class Container extends Component
|
|||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private void addNotifyContainerChildren()
|
||||
{
|
||||
synchronized (getTreeLock ())
|
||||
{
|
||||
for (int i = ncomponents; --i >= 0; )
|
||||
{
|
||||
|
@ -1116,6 +1158,7 @@ public class Container extends Component
|
|||
enableEvents(component[i].eventMask);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Nested classes.
|
||||
|
@ -1189,6 +1232,8 @@ public class Container extends Component
|
|||
* @return the number of accessible children
|
||||
*/
|
||||
public int getAccessibleChildrenCount()
|
||||
{
|
||||
synchronized (getTreeLock ())
|
||||
{
|
||||
int count = 0;
|
||||
int i = component == null ? 0 : component.length;
|
||||
|
@ -1197,6 +1242,7 @@ public class Container extends Component
|
|||
count++;
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the nth accessible child of the containing accessible object.
|
||||
|
@ -1205,6 +1251,8 @@ public class Container extends Component
|
|||
* @return the accessible child, or null
|
||||
*/
|
||||
public Accessible getAccessibleChild(int i)
|
||||
{
|
||||
synchronized (getTreeLock ())
|
||||
{
|
||||
if (component == null)
|
||||
return null;
|
||||
|
@ -1216,6 +1264,7 @@ public class Container extends Component
|
|||
return (Accessible) component[index];
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the accessible child located at point (in the parent's
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue