[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform.swt] Re: SWTException in ColumnViewerEditor.activateCellEditor

Tom Schindl wrote:
We don't support disposing, event-loop spinning, .... while the
JFace-Code is running! You should defer the disposal using
Display#asyncExec().

Tom



Then why does the code in applyEditorValue() check for isDisposed()?

Florin


Florin Mateoc schrieb:
Hi all,

I get a "Widget is disposed" exception in
ColumnViewerEditor.activateCellEditor(ColumnViewerEditorActivationEvent),
 when executing the line:

    this.cell.getItem().addDisposeListener(disposeListener);

After investigating a bit, the disposal happens while executing the
method handleEditorActivationEvent(ColumnViewerEditorActivationEvent),
inside the applyEditorValue() call. At that time, the cell was already
retrieved and stored as the source of the event, and it continues to be
used in handleEditorActivationEvent, although the call to
applyEditorValue can obviously (and does) modify the tree.

In my case, the disposal happens inside the call to
saveEditorValue(CellEditor) called from applyEditorValue. If I look at
the code in applyEditorValue, it seems to expect tree modification,
since it has tests for isDisposed() all around, so I assume this is a
bug. I think it could be fixed easily be replacing the line:

    this.cell = (ViewerCell) event.getSource();

from handleEditorActivationEvent(ColumnViewerEditorActivationEvent) with
something like:

    this.cell = viewer.getCell(new Point(event.sourceEvent.x,
event.sourceEvent.y));

in order to get the potentially updated cell instead of the stale one.

If I missed something, please don't hesitate to point it out.
Thank you,

Florin