Project: SWT
Bug 51088 Patch(es) to fix redraw bug after ControlEditors close.
Reported: 2004-02-02 21:50:17 | Status: resolved fixed

Currently on the Mac, when a Control is disposed, it does not tell the parent to reset the clipping regions. This is what causes the area under a ControlEditor to not be redrawn properly after editing is complete. The most obvious hack to fix this (which is probably not the correct one) is to call invalidateVisibleRegion in releaseWidget(): Index: Control.java ============================================================ ======= retrieving revision 1.128 diff -u -r1.128 Control.java --- Control.java 18 Dec 2003 19:34:23 -0000 1.128 +++ Control.java 3 Feb 2004 02:14:50 -0000 @@ -1619,6 +1619,9 @@ menu.dispose (); } if (visibleRgn != 0) OS.DisposeRgn (visibleRgn); + if (parent != null && !parent.isDisposed()) { + parent.invalidateVisibleRegion (handle); + } visibleRgn = 0; menu = null; parent = null; There was at least one odd piece of fallout from making this change. In the FileExplorer app I have been working on with Steve, I got the following walkback when closing the shell: Exception in thread "main" java.lang.NullPointerException at org.eclipse.swt.widgets.ToolBar.invalidateChildrenVisibleRegion(ToolBar.java:308) at org.eclipse.swt.widgets.Control.invalidateVisibleRegion(Control.java:1150) at org.eclipse.swt.widgets.Control.releaseWidget(Control.java:1623) at org.eclipse.swt.widgets.Scrollable.releaseWidget(Scrollable.java:336) at org.eclipse.swt.widgets.Composite.releaseWidget(Composite.java:493) at org.eclipse.swt.widgets.Widget.releaseResources(Widget.java:1085) at org.eclipse.swt.widgets.Composite.releaseChildren(Composite.java:487) at org.eclipse.swt.widgets.Composite.releaseWidget(Composite.java:492) at org.eclipse.swt.widgets.ToolBar.releaseWidget(ToolBar.java:399) at org.eclipse.swt.widgets.Widget.releaseResources(Widget.java:1085) at org.eclipse.swt.widgets.Composite.releaseChildren(Composite.java:487) at org.eclipse.swt.widgets.Composite.releaseWidget(Composite.java:492) at org.eclipse.swt.widgets.Canvas.releaseWidget(Canvas.java:127) at org.eclipse.swt.widgets.Decorations.releaseWidget(Decorations.java:328) at org.eclipse.swt.widgets.Shell.releaseWidget(Shell.java:983) at org.eclipse.swt.widgets.Widget.dispose(Widget.java:476) at org.eclipse.swt.widgets.Shell.closeWidget(Shell.java:390) at org.eclipse.swt.widgets.Shell.kEventWindowClose(Shell.java:789) at org.eclipse.swt.widgets.Widget.windowProc(Widget.java:1626) at org.eclipse.swt.widgets.Display.windowProc(Display.java:2825) at org.eclipse.swt.internal.carbon.OS.SendEventToEventTarget(Native Method) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1903) at part3.fileexplorer.FileExplorer.main(FileExplorer.java:68) The odd thing is, invalidateChildrenVisibleRegion is failing in this case because the itemCount is non-zero, even though the items array has been nulled out: void invalidateChildrenVisibleRegion (int control) { super.invalidateChildrenVisibleRegion (control); for (int i=0; i<itemCount; i++) { ToolItem item = items [i]; item.resetVisibleRegion (control); } } If I patch the releaseWidget method for ToolBar to set itemCount to zero, like this... Index: ToolBar.java ============================================================ ======= retrieving revision 1.20 diff -u -r1.20 ToolBar.java --- ToolBar.java 7 May 2003 22:25:37 -0000 1.20 +++ ToolBar.java 3 Feb 2004 02:23:42 -0000 @@ -394,6 +394,7 @@ ToolItem item = items [i]; if (!item.isDisposed ()) item.releaseResources (); } + itemCount = 0; items = null; super.releaseWidget (); } ... then the example appears to work perfectly. This last change, seems like a good thing to do anyway. I don't have high confidence in the first one, but it definitely fixes the "in place rename does not redraw the tree" bug in my example, so something like that is needed.

Files changed in fix:
bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Control.java bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/ToolBar.java bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/ToolItem.java