Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTill Brychcy2018-09-27 20:26:19 +0000
committerTill Brychcy2018-11-18 10:49:17 +0000
commit6b498d085fe2e1e0f03402782ee7c8203d9d2202 (patch)
tree5774f48c26f91146e850ac8118183178c67868d0
parentd1cdb8f0988641c54fc9a511883d3e9f03dc9323 (diff)
downloadeclipse.platform.swt-6b498d085fe2e1e0f03402782ee7c8203d9d2202.tar.gz
eclipse.platform.swt-6b498d085fe2e1e0f03402782ee7c8203d9d2202.tar.xz
eclipse.platform.swt-6b498d085fe2e1e0f03402782ee7c8203d9d2202.zip
Bug 538377 - Java crash after
org.eclipse.swt.internal.cocoa.NSApplication.setDelegate on macos 10.14 mojave with touch bar Change-Id: I1581bad23de972009bf5308bf66a8ebeef03c040
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java18
1 files changed, 15 insertions, 3 deletions
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 50b853c450..fd96736ac6 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -903,7 +903,20 @@ void createDisplay (DeviceData data) {
applicationCallback6 = new Callback(clazz, "applicationProc", 6);
long /*int*/ proc6 = applicationCallback6.getAddress();
if (proc6 == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
- cls = OS.objc_allocateClassPair(OS.object_getClass(application.id), className, 0);
+ long superClassID = OS.object_getClass(application.id);
+ if (new NSObject(superClassID).className().getString().equals("NSKVONotifying_NSApplication")) {
+ /*
+ * Key-value observing has been activated for the application instance. This can
+ * happen when launching nested eclipse instances on macOS 10.14 with a touch
+ * bar. Unfortunately, dynamically subclassing KVO classes doesn't work.
+ * Workaround is to switch back to plain NSApplication as super class. SWT
+ * currently doesn't support the touch bar anyway, so this shouldn't break
+ * anything and is better than a crash.
+ */
+ superClassID = OS.objc_lookUpClass("NSApplication");
+ }
+
+ cls = OS.objc_allocateClassPair(superClassID, className, 0);
OS.class_addMethod(cls, OS.sel_sendEvent_, proc3, "@:@");
OS.class_addMethod(cls, OS.sel_nextEventMatchingMask_untilDate_inMode_dequeue_, proc6, "@:i@@B");
OS.class_addMethod(cls, OS.sel_isRunning, proc2, "@:");
@@ -916,7 +929,6 @@ void createDisplay (DeviceData data) {
if (OS.objc_lookUpClass (className) == 0) {
long /*int*/ appProc3 = applicationCallback3.getAddress();
if (appProc3 == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
- cls = OS.objc_allocateClassPair(OS.class_NSObject, className, 0);
long /*int*/ appProc4 = applicationCallback4.getAddress();
if (appProc4 == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
cls = OS.objc_allocateClassPair(OS.class_NSObject, className, 0);

Back to the top