private void UpdateChildren(AccessiblePath [] childPaths)
{
bool initializing = (children == null);
if (StateSet.Contains (StateType.ManagesDescendants) ||
(Role == Role.Filler)) {
// Do not cache filler to work around BGO#577392
if (!(children is UncachedChildren))
children = new UncachedChildren (this);
} else {
Accessible [] oldChildren = null;
if (children is List<Accessible>) {
oldChildren = new Accessible [children.Count];
children.CopyTo (oldChildren, 0);
}
children = new List<Accessible> ();
children.Clear ();
foreach (AccessiblePath path in childPaths) {
Accessible child = Registry.GetElement (path, true);
if (!initializing &&
(oldChildren == null ||
Array.IndexOf (oldChildren, child) == -1))
Desktop.RaiseChildAdded (this, child);
children.Add (child);
}
if (!initializing && oldChildren != null)
foreach (Accessible child in oldChildren)
if (!PathListContains (childPaths, child.application.name, child.path))
Desktop.RaiseChildRemoved (this, child);
}
}