### Eclipse Workspace Patch 1.0 #P org.eclipse.swt Index: Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java,v retrieving revision 1.212 diff -u -r1.212 Combo.java --- Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java 23 Dec 2010 19:18:09 -0000 1.212 +++ Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java 10 Feb 2011 18:26:31 -0000 @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.swt.widgets; +import java.util.HashSet; +import java.util.Set; import org.eclipse.swt.*; import org.eclipse.swt.internal.*; @@ -571,35 +573,28 @@ } int /*long*/ findPopupHandle (int /*long*/ oldList) { + // We get two lists of top-level window handles, one before creation of the combo box + // and one after. The first window handle that is present in the second list but not in + // the first one is assumed to be the handle of the popup window of the combo box. int /*long*/ hdl = 0; - int /*long*/ currentList = OS.gtk_window_list_toplevels(); - int /*long*/ oldFromList = oldList; - int /*long*/ newFromList = currentList; - boolean isFound; - while (newFromList != 0) { - int /*long*/ newToplevel = OS.g_list_data(newFromList); - isFound = false; - oldFromList = oldList; - while (oldFromList != 0) { - int /*long*/ oldToplevel = OS.g_list_data(oldFromList); - if (newToplevel == oldToplevel) { - isFound = true; - break; - } - oldFromList = OS.g_list_next(oldFromList); - } - if (!isFound) { - hdl = newToplevel; + Set oldHandles = new HashSet(400); + for (int item = oldList; item != 0; item = OS.g_list_next(item)) { + oldHandles.add(new Integer(OS.g_list_data(item))); + } + + int /*long*/ newList = OS.gtk_window_list_toplevels(); + for (int item = newList; item != 0; item = OS.g_list_next(item)) { + int handle = OS.g_list_data(item); + if (!oldHandles.contains(new Integer(handle))) { + hdl = handle; break; } - newFromList = OS.g_list_next(newFromList); } OS.g_list_free(oldList); - OS.g_list_free(currentList); + OS.g_list_free(newList); return hdl; } - void findButtonHandle() { /* * Feature in GTK. There is no API to query the button