gef-classic icon indicating copy to clipboard operation
gef-classic copied to clipboard

Move up null check in GEF viewer when the selected editpart is updated.

Open ptziegler opened this issue 1 year ago • 1 comments

The selection inside a GEF viewer is assumed to always be non-null. But because the (implicit) null check is done after the editpart is added to the internal list, it leaves the viewer in an inconsistent state.

To avoid this, the null check is done earlier, so that the exception is thrown before the internal model is modified.

ptziegler avatar May 13 '24 18:05 ptziegler

The problem can be observed in e.g. the following lines of SelectionManager.appendSelection():

selection.remove(editpart);
selection.add(editpart);
editpart.setSelected(EditPart.SELECTED_PRIMARY);

If the editpart is null, it is added to the internal list before an exception is thrown. When the selection is changed, an exception is thrown again, when the null-selection is removed again. I don't see how this can be the desired behavior and I don't believe this is something clients should rely on.

ptziegler avatar May 13 '24 19:05 ptziegler