Bug 109281 [Viewers] ContentViewer does not null out input on handleDisposed
While tracking down a possible leak I were calling viewer.setInput(null) when viewer.getInput()!=null but that gave an assert exception because the ContentProvider had been nulled out in handleDisposed(). I suggest you also null out Input to keep the state consistent since the code actually call inputChanged as if input had been nulled out. protected void handleDispose(DisposeEvent event) { if (contentProvider != null) { contentProvider.inputChanged(this, getInput(), null); contentProvider.dispose(); contentProvider = null; input = null; // add this line for consistency } if (labelProvider != null) { labelProvider.removeListener(labelProviderListener); labelProvider.dispose(); labelProvider = null; } }
bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ContentViewer.java
* <p>
 * Implementing a concrete content viewer typically involves the following steps:
 * <ul>
 * <li>
 * create SWT controls for viewer (in constructor) (optional)
 * </li>
 * <li>
 * initialize SWT controls from input (inputChanged)
 * </li>
 * <li>
 * define viewer-specific update methods
 * </li>
 * <li>
 * support selections (<code>setSelection</code>, <code>getSelection</code>)
 * </ul>
 * </p>
 */
public abstract class ContentViewer extends Viewer {
    /**
     * This viewer's content provider, or <code>null</code> if none.
     */
    private IContentProvider contentProvider = null;
    /**
     * This viewer's input, or <code>null</code> if none.
     * The viewer's input provides the "model" for the viewer's content.
     */
    private Object input = null;
    /**
     * This viewer's label provider. Initially <code>null</code>, but
     * lazily initialized (to a <code>SimpleLabelProvider</code>).