### Eclipse Workspace Patch 1.0 #P org.eclipse.swt Index: Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CCombo.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CCombo.java,v retrieving revision 1.132 diff -u -r1.132 CCombo.java --- Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CCombo.java 1 Oct 2009 18:05:43 -0000 1.132 +++ Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CCombo.java 1 Oct 2009 20:07:25 -0000 @@ -59,6 +59,7 @@ Shell _shell; static final String PACKAGE_PREFIX = "org.eclipse.swt.custom."; //$NON-NLS-1$ + static final String SHELL_KEY = "org.eclipse.swt.custom.CCombo.SHELL"; //$NON-NLS-1$ /** * Constructs a new instance of this class given its parent @@ -361,17 +362,12 @@ notifyListeners(SWT.Dispose, event); event.type = SWT.None; - if (popup != null && !popup.isDisposed ()) { - list.removeListener (SWT.Dispose, listener); - popup.dispose (); - } + disposePopup (); Shell shell = getShell (); shell.removeListener (SWT.Deactivate, listener); Display display = getDisplay (); display.removeFilter (SWT.FocusIn, filter); - popup = null; text = null; - list = null; arrow = null; _shell = null; break; @@ -432,9 +428,14 @@ checkWidget (); text.copy (); } -void createPopup(String[] items, int selectionIndex) { - // create shell and list - popup = new Shell (getShell (), SWT.NO_TRIM | SWT.ON_TOP); +void createPopup(String[] items, int selectionIndex) { + Shell shell = getShell(); + popup = (Shell) shell.getData (SHELL_KEY); + if (popup == null || popup.isDisposed ()) { + popup = new Shell (getShell (), SWT.NO_TRIM | SWT.ON_TOP); + shell.setData (SHELL_KEY, popup); + } + int style = getStyle (); int listStyle = SWT.SINGLE | SWT.V_SCROLL; if ((style & SWT.FLAT) != 0) listStyle |= SWT.FLAT; @@ -444,6 +445,7 @@ if (font != null) list.setFont (font); if (foreground != null) list.setForeground (foreground); if (background != null) list.setBackground (background); + list.setVisible(false); int [] popupEvents = {SWT.Close, SWT.Paint, SWT.Deactivate}; for (int i=0; i displayRect.y + displayRect.height) y = parentRect.y - height; if (x + width > displayRect.x + displayRect.width) x = displayRect.x + displayRect.width - listRect.width; popup.setBounds (x, y, width, height); + list.setVisible (true); popup.setVisible (true); if (isFocusControl()) list.setFocus (); } @@ -995,7 +1009,7 @@ }); } boolean isDropped () { - return popup.getVisible (); + return list.isVisible(); } public boolean isFocusControl () { checkWidget(); @@ -1131,6 +1145,7 @@ text.paste (); } void popupEvent(Event event) { + if (!isDropped()) return; switch (event.type) { case SWT.Paint: // draw black rectangle around list