Bug 365280 - Combo box closes self when Mozilla Browser present
(improved)
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/cocoa/org/eclipse/swt/browser/MozillaDelegate.java b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/cocoa/org/eclipse/swt/browser/MozillaDelegate.java
index 890f5a6..df87e15 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/cocoa/org/eclipse/swt/browser/MozillaDelegate.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/cocoa/org/eclipse/swt/browser/MozillaDelegate.java
@@ -23,7 +23,7 @@
 	Listener listener;
 	boolean hasFocus;
 
-	static final String SET_MOZILLA_COUNT = "org.eclipse.swt.internal.setMozillaCount"; //$NON-NLS-1$
+	static final String MOZILLA_RUNNING = "org.eclipse.swt.internal.mozillaRunning"; //$NON-NLS-1$
 
 MozillaDelegate (Browser browser) {
 	super ();
@@ -125,7 +125,7 @@
 }
 
 int createBaseWindow (nsIBaseWindow baseWindow) {
-	browser.getDisplay ().setData (SET_MOZILLA_COUNT, new Integer (Mozilla.BrowserCount));
+	browser.getDisplay ().setData (MOZILLA_RUNNING, Boolean.TRUE);
 
 	/*
 	* Feature of Mozilla on OSX.  Mozilla replaces the OSX application menu whenever
@@ -194,7 +194,6 @@
 		eventShell = null;
 		listener = null;
 	}
-	browser.getDisplay ().setData (SET_MOZILLA_COUNT, new Integer (Mozilla.BrowserCount));
 	browser = null;
 }
 
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/Mozilla.java b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/Mozilla.java
index 481c148..c4ed39d 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/Mozilla.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/Mozilla.java
@@ -2708,12 +2708,11 @@
 	}
 	functions = null;
 
-	BrowserCount--;
-
 	delegate.onDispose (embedHandle);
 	delegate = null;
 
 	embedHandle = 0;
+	BrowserCount--;
 }
 
 void Activate () {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java
index 29435c0..40db02f 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java
@@ -176,8 +176,8 @@
 	Callback cursorSetCallback;
 
 	boolean comboPoppedUp = false;
-	int mozillaCount;
-	static final String SET_MOZILLA_COUNT = "org.eclipse.swt.internal.setMozillaCount"; //$NON-NLS-1$
+	boolean mozillaRunning;
+	static final String MOZILLA_RUNNING = "org.eclipse.swt.internal.mozillaRunning"; //$NON-NLS-1$
 
 	// the following Callbacks are never freed
 	static Callback windowCallback2, windowCallback3, windowCallback4, windowCallback5, windowCallback6;
@@ -4372,8 +4372,8 @@
 		}
 	}
 	
-	if (key.equals (SET_MOZILLA_COUNT)) {
-		mozillaCount = ((Integer)value).intValue ();
+	if (key.equals (MOZILLA_RUNNING)) {
+		mozillaRunning = ((Boolean)value).booleanValue ();
 	}
 
 	/* Remove the key/value pair */
@@ -4882,7 +4882,7 @@
 		 * workaround is to detect this case and to not return the event that would trigger
 		 * this to happen.
 		 */
-		if (comboPoppedUp && mozillaCount > 0 && dequeue != 0) {
+		if (comboPoppedUp && mozillaRunning && dequeue != 0) {
 			NSEvent event = new NSEvent(result);
 			if (event.type() == OS.NSApplicationDefined) {
 				return 0;