rreckel
8 May 2008, 1:35 AM
Hi
The problem occurs when setting the input of a TreeTableViewer if the TreeTableViewer has already an input with children.
So the first setInput works ok.
But the second throws an NPE in TreeItem.remove(TreeItem item):
public void remove(TreeItem item) {
if (!children.contains(item)) {
return;
}
TreeEvent te = new TreeEvent(tree);
te.item = this;
te.child = item;
if (fireEvent(Events.BeforeRemove, te)) {
children.remove(item);
tree.unregisterItem(item);
item.tree = null;
item.parentItem = null;
if (rendered && item.rendered) {
ui.removeItem(item);
}
fireEvent(Events.Remove, te);
}
}
The line throwing the NPE is:
ui.removeItem(item) because ui is null!
It seems this happens because in the constructor of RootTreeTableItem rendered is set to true, and therefore onRender() is never called.
And because onRender() is never called, getTreeItemUI() is never called (which initiaslizes the ui).
So, if onRender should not be called, it seems that the ui has to be initialized in an other way as getTreeItemUI()......
Is my analysis correct?
Is this a bug?
Thanks for your help
Roll
The problem occurs when setting the input of a TreeTableViewer if the TreeTableViewer has already an input with children.
So the first setInput works ok.
But the second throws an NPE in TreeItem.remove(TreeItem item):
public void remove(TreeItem item) {
if (!children.contains(item)) {
return;
}
TreeEvent te = new TreeEvent(tree);
te.item = this;
te.child = item;
if (fireEvent(Events.BeforeRemove, te)) {
children.remove(item);
tree.unregisterItem(item);
item.tree = null;
item.parentItem = null;
if (rendered && item.rendered) {
ui.removeItem(item);
}
fireEvent(Events.Remove, te);
}
}
The line throwing the NPE is:
ui.removeItem(item) because ui is null!
It seems this happens because in the constructor of RootTreeTableItem rendered is set to true, and therefore onRender() is never called.
And because onRender() is never called, getTreeItemUI() is never called (which initiaslizes the ui).
So, if onRender should not be called, it seems that the ui has to be initialized in an other way as getTreeItemUI()......
Is my analysis correct?
Is this a bug?
Thanks for your help
Roll