diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Combo.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Combo.java index 0185ae234ee..02801327de8 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Combo.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Combo.java @@ -1144,7 +1144,7 @@ void menuDidClose(long id, long sel, long menu) { @Override void mouseDown(long id, long sel, long theEvent) { - // If the control is diposed in below 'super.mouseDown()', both fields + // If the control is disposed in below 'super.mouseDown()', both fields // 'view' and 'display' will be nulled. Hence keep their references: final Display display = this.display; final NSView view = this.view; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Menu.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Menu.java index ecffa1b232d..597dc10f15e 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Menu.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Menu.java @@ -264,6 +264,9 @@ void _setVisible (boolean visible) { // Hold on to window in case it is disposed while the popup is open. window.retain(); + // The menu might get disposed in a NS* call below (#922), so better + // keep a reference to `display` here. + final Display display = this.display; // NSMenu processes events on its own while the popup is open. display.sendPreExternalEventDispatchEvent (); NSEvent nsEvent = NSEvent.otherEventWithType(OS.NSApplicationDefined, location, 0, 0.0, window.windowNumber(), window.graphicsContext(), (short)0, 0, 0);