JGoView.newLink problem

I’ve got another weird one in my Eclipse RCP based app.

In my architechture, I extend JGoView (ProcessJGoView) to act as visual editor for my domain model. For example, when the user draws a link between ports on two nodes, events are sent up to the domain model that create a data representation of that link. A number of different views listen to events on the domain model and update themselves accordingly.

In fact, my extension of the JGoDocument (ProcessJGoDocument) shown by the above ProcessJGoView is such a listener. So when the user draws a new link this is what I want to happen:

  1. The creation of the default new JGoLink in the JGoDocument is cancelled.
  2. An event is fired from ProcessJGoView to request the creation of the domain model’s analog to the link the user just indicated.
  3. Domain model creates the analog and fires an event to all listeners that this new element has been added.
  4. ProcessJGoDocument creates and adds a VisualLink (extension of JGoLink) to the document which creates the actual link the user indicated.

To do this I’ve overridden ProcessJGoView.newLink:

public void newLink(JGoPort from, JGoPort to) {

    //Cancel the drawing of the link
    //Create a link
    JGoLink link = new JGoLink(from, to);
    //Send a request for a new link up the chain
    fireUpdate(REQUEST_LINK_EVENT, 0, link);

This works beautifully when I first open the editor (Eclipse RCP) that contains the ProcessJGoView. But when I close the editor and then reopen it, then use the mouse to gesture a new link, the domain model updates correctly, but the new VisualLink is not displayed. An error occurs when trying to add it to the document with:


where transitionLayer is a JGoLayer where I locate such objects.

Specifically, somewhere in the call stack after this call it gets to the ProcessJGoView.checkWidget method (actually from org.eclipse.swt.widgets.Widget)

protected void checkWidget () {
Display display = this.display;
if (display == null) error (SWT.ERROR_WIDGET_DISPOSED);
if (display.thread != Thread.currentThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
if ((state & DISPOSED) != 0) error (SWT.ERROR_WIDGET_DISPOSED);

display for some reason is now null and so an exception is thrown and my new VisualLink is never displayed.

All of which is a long winded way of saying, do you see what I’m doing wrong? How did display get set to null? Am I forgetting something in newLink? Maybe it’s an Eclipse issue but I though I’d start with you.


I have no idea how this could happen. I don’t recall ever encountering or even hearing of such a problem. Unless you have somehow constructed a JGoView that is different from the one you are really using/showing.

Your hint sent me in the right direction, thanks. I wasn’t doing a good job of disposing of listeners, so the error was occurring on the instance of the editor that was supposedly closed. Everything appears to be working fine now.