ccocco_dw
2 Nov 2011, 4:08 AM
The code in TreePanel throws sporadic exceptions when dragging and dropping tree nodes from one parent to another, due to the findChildren() method assuming the call to findNode() always returns a valid value and thus attempts to dereference it even when it's null, causing a NullPointerException to be thrown. In addition to findChildren(), there are number of other places in this class where the return value from findNode() is not checked and thus potentially have the same problem when null is returned. This breaks drag and drop in my usage of it because it attempts to call onAdd(), update(), and clean() when a tree node is dropped onto a new parent, and in turn findNode() is called for the moved tree node and it returns null.
Please check the return value from findNode() before using it in this class:
private void findChildren(M parent, List<M> list, boolean onlyVisible) {
for (M child : store.getChildren(parent)) {
list.add(child);
if (!onlyVisible || findNode(child).isExpanded()) {
findChildren(child, list, onlyVisible);
}
}
}
Please check the return value from findNode() before using it in this class:
private void findChildren(M parent, List<M> list, boolean onlyVisible) {
for (M child : store.getChildren(parent)) {
list.add(child);
if (!onlyVisible || findNode(child).isExpanded()) {
findChildren(child, list, onlyVisible);
}
}
}