Bug 297339

Summary: Edit part selection is not handled in AbstractEditPartViewer in certain conditions
Product: [Tools] GEF Reporter: Tim Usaty <tusaty.eclipse>
Component: GEF-Legacy GEF (MVC)Assignee: gef-inbox <gef-inbox>
Status: NEW --- QA Contact:
Severity: minor    
Priority: P3 CC: ahunter.eclipse
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Tim Usaty CLA 2009-12-09 09:19:13 EST
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.15) Gecko/2009101601 Firefox/3.0.15
Build Identifier: 20090619-0625

There is no check for null pointer in  
AbstractEditPartViewer.addSelectionChangedListener(ISelectionChangedListener listener). 

If I add the null listener there is no exception raised. 
But after that the AbstractEditPartViewer.fireSelectionChanged() method works wrong, because there is no any protection against null pointer exception inside. Thus the firing of selection listeners is stopped, after the null listener is reached. 


Reproducible: Always

Steps to Reproduce:
 /* 
  * here I get a graphical
  *  viewer (any implementation for org.eclipse.gef.GraphicalViewer, 
  *  viewer is inheritor of org.eclipse.gef.ui.parts.AbstractEditPartViewer)
  */
GraphicalViewer viewer = ... ;
 /*
  * here I create changes listener 
  *
  */ 
ISelectionChangedListener listener = ...;
/*
 * here I assign the null listener,
 * no exception is raised
 */
viewer.addSelectionListener(null); 
/*
 * here I assign the null listener,
 * no exception is raised
 */
viewer.addSelectionListener(null); 
/*
 * here I assign the null listener,
 * no exception is raised
 */
viewer.addSelectionListener(null); 

/*
 * here I assign the null listener,
 * no exception is raised
 */
viewer.addSelectionListener(listener); 

/*
 *  last listener will never be executed in
 *  the current AbstractEditPartViewer.fireSelectionChanged() implementation
 *  
 */
Comment 1 Anthony Hunter CLA 2010-01-13 17:22:25 EST
(In reply to comment #0)
> If I add the null listener there is no exception raised. 
> But after that the AbstractEditPartViewer.fireSelectionChanged() method works
> wrong, because there is no any protection against null pointer exception
> inside. Thus the firing of selection listeners is stopped, after the null
> listener is reached. 

I am guessing there is some reason why you cannot simply not add the null listener?