Bug 51575 - Null pointer check missing
Summary: Null pointer check missing
Status: RESOLVED DUPLICATE of bug 4416
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Steve Northover CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-02-10 21:35 EST by Wynne Crisman CLA
Modified: 2004-02-13 15:13 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Wynne Crisman CLA 2004-02-10 21:35:03 EST
Table.getColumn(int) Should check for a null columns field before trying to
access the array elements.  

Scenario: If the table is disposing it is not flaged as disposed until after
dispose events are fired.  A listener to the table dispose may try to dispose of
its self and in doing so may try to retreive table items (as in my case).  The
listener would not know from calling table.isDisposed() whether the table is
being disposed.  In such a case, either the table should be marked as disposed,
or a call to getColumn(int) should return null.
Comment 1 Grant Gayed CLA 2004-02-11 09:46:54 EST
SN shouldn't the Table still be in its intact state when Dispose listeners are 
invoked?  Snippet:

public static void main (String [] args) {
	Display display = new Display ();
	final Shell shell = new Shell (display);
	shell.setBounds(10,10,200,200);
	final Table table = new Table(shell, SWT.NONE);
	table.setBounds(10,10,160,100);
	new TableColumn(table,SWT.NONE);
	new TableColumn(table,SWT.NONE);
	new TableColumn(table,SWT.NONE);
	Button button = new Button (shell, SWT.PUSH);
	button.setBounds(10,130,60,30);
	button.setText("Dispose");
	button.addListener(SWT.Selection, new Listener() {
		public void handleEvent(Event event) {
			table.dispose();
		}
	});
	table.addListener(SWT.Dispose, new Listener() {
		public void handleEvent(Event event) {
			table.getColumn(1);
		}
	});
	shell.open ();
	while (!shell.isDisposed()) {
		if (!display.readAndDispatch ()) display.sleep ();
	}
	display.dispose ();
}
Comment 2 Steve Northover CLA 2004-02-13 15:13:42 EST
Disposing happens from the leaves to the roots.  At the time that the table is 
disposed, the table items and columns have already been disposed.  There is a 
very old problem report that captures this "bug".  In order to really fix it, 
we would have to traverse the widget tree 3 times (making dispose() slow).

*** This bug has been marked as a duplicate of 4416 ***