Bug 297339 - Edit part selection is not handled in AbstractEditPartViewer in certain conditions
Summary: Edit part selection is not handled in AbstractEditPartViewer in certain condi...
Status: NEW
Alias: None
Product: GEF
Classification: Tools
Component: GEF-Legacy GEF (MVC) (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 minor (vote)
Target Milestone: ---   Edit
Assignee: gef-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-12-09 09:19 EST by Tim Usaty CLA
Modified: 2010-01-13 17:22 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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?