Skip to content

Commit

Permalink
Fix logged NPE in ViewerUpdateMonitor constructor eclipse-platform#1500
Browse files Browse the repository at this point in the history
There is a logged NPE in the constructor of ViewerUpdateMonitor when
viewerInput is null. This can happen sporadically when updating tree
elements during Viewer.setInput(null).

This commit adds a check to avoid creating children updates when the
viewer input is null.

Fixes eclipse-platform#1500
  • Loading branch information
mx990 committed Aug 14, 2024
1 parent 27ff234 commit c5e7848
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1185,9 +1185,10 @@ void doUpdateElement(TreePath parentPath, int modelIndex) {
Assert.isTrue( getViewer().getDisplay().getThread() == Thread.currentThread() );

Object parent = getElement(parentPath);
Object viewerInput = getViewer().getInput();
IElementContentProvider contentAdapter = ViewerAdapterService.getContentProvider(parent);
if (contentAdapter != null) {
ChildrenUpdate request = new ChildrenUpdate(this, getViewer().getInput(), parentPath, parent, modelIndex, contentAdapter);
if (viewerInput != null && contentAdapter != null) {
ChildrenUpdate request = new ChildrenUpdate(this, viewerInput, parentPath, parent, modelIndex, contentAdapter);
schedule(request);
}
}
Expand Down

0 comments on commit c5e7848

Please sign in to comment.