Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 243996 - getFocusCell throws an exception when the last grid column was disposed
Summary: getFocusCell throws an exception when the last grid column was disposed
Status: CLOSED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Nebula (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P2 normal with 2 votes (vote)
Target Milestone: ---   Edit
Assignee: Thomas Schindl CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-08-13 05:49 EDT by Jacek Kolodziejczyk CLA
Modified: 2021-07-05 11:39 EDT (History)
4 users (show)

See Also:


Attachments
Patch set the focusColumn to null when the column (734 bytes, patch)
2009-06-07 19:21 EDT, Jacek Kolodziejczyk CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jacek Kolodziejczyk CLA 2008-08-13 05:49:32 EDT
Steps to reproduce:
        Display display = new Display();
        Shell shell = new Shell(display);
        shell.setLayout(new FillLayout());

        Grid grid = new Grid(shell, SWT.NONE);
        grid.setCellSelectionEnabled(true);

        GridColumn column = new GridColumn(grid, SWT.NONE);

        grid.setFocusColumn(column);        
        column.dispose();
        grid.getFocusCell();
        
        while (display.readAndDispatch());
        display.dispose();

In my opinion the Grid.removeColumn method should set focusColumn = null
Comment 1 David Kyle CLA 2008-08-19 12:18:01 EDT
I just stumbled across this bug. I took Jacek's suggestion one step farther.

    void removeColumn(GridColumn column)
    {
        // blah blah blah
        if (focusColumn == column) {
            focusColumn = null;
        }
        // blah blah blah
     }
Comment 2 Thomas Schindl CLA 2009-04-24 09:30:35 EDT
Makes sense to me. Want to provide a patch? The it gets P1
Comment 3 Jacek Kolodziejczyk CLA 2009-06-07 19:21:35 EDT
Created attachment 138532 [details]
Patch set the focusColumn to null when the column

I wonder though if we should not go even another step further, which would be to move the focus to the next visible column on the right - or to the left if there is nothing on the right, on both column disposing and hiding - see bug 238713.

And the same for item hiding and disposing.
Comment 4 Markus Stier CLA 2013-11-25 04:15:16 EST
Same happens when the last row is removed from the grid. 
focusColumn and focusItem should be set to null when appropriate. Since it should be easy to fix it would be nice to push it to P1.
Comment 5 Thomas Schindl CLA 2014-12-09 16:26:11 EST
I really wonder how this slipped through that long - naturally the patch didn't apply anymore so I pushed my own version with http://git.eclipse.org/c/nebula/org.eclipse.nebula.git/commit/?id=272199aec6aee8d3b82e3eac8c0fec20beb2d8c7
Comment 6 Laurent CARON CLA 2019-09-25 08:31:26 EDT
Tried today => the bug has been fixed in the past.