PDA

View Full Version : [CLOSED] NPE on TreeTableViewer.setInput



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

rreckel
8 May 2008, 5:51 AM
Sorry Darrell

I just read that the Viewer code will be removed in beta3.
So I think this Bug is obsolete.....

Roll

darrellmeyer
12 May 2008, 12:07 PM
No problem. You want to look at TreeStore and TreeBinder in the new code.

axeldxter
13 May 2008, 11:37 AM
Hi

I already fixed the bug. It takes just adding the line ui = getTreeItemUI(); after render = true in the RootTreeTableItem constructor. But I'm using the open source license of the beta 2. The TreeStore and TreeBinder are already available with the commercial license or we have to wait until beta 3?

Thanks