weimingtom / opal

Automatically exported from code.google.com/p/opal
0 stars 0 forks source link

TransitionComposite - SWT Exception when child is disposed #18

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I want to dynamically create and remove some contents of the 
TransitionComposite.
If i dispose a child of the composite, it generate a SWT Exception : Widget is 
disposed.
This is due to the fact that the computeSize method uses the private attribute 
'controls' and compute the size of each element of this list regardless their 
disposed state.

Original issue reported on code.google.com by gherve1...@gmail.com on 28 Oct 2013 at 1:27

GoogleCodeExporter commented 9 years ago
The change below resolve the problem :

public void addControl(final Control control) {
        checkWidget();
        if(!control.isDisposed()) {
            this.controls.add(control);
            if (this.controls.size() == 1) {
                control.setVisible(true);
            } else {
                control.setVisible(false);
            }

            control.addListener(SWT.Dispose, new Listener() {
                @Override
                public void handleEvent(Event event) {
                    controls.remove((Control) event.widget);
                }
            });
        }
    }

Original comment by gherve1...@gmail.com on 28 Oct 2013 at 1:52

GoogleCodeExporter commented 9 years ago
Bug fixed in the next release (0.9.7), thank your for your correction.

Original comment by laurent....@gmail.com on 16 Nov 2013 at 10:20