diff options
author | Till Brychcy | 2018-09-27 20:26:19 +0000 |
---|---|---|
committer | Sravan Kumar Lakkimsetti | 2021-03-29 14:37:18 +0000 |
commit | 51058aafe04e9ddf73eb8929e98359d9a9c1ac97 (patch) | |
tree | c2c4bdebbd288f49b0235b6ee6fb22fb86144c26 | |
parent | c74357157e2296ed3a4a717eadf3321bf3460b4e (diff) | |
download | eclipse.platform.swt-51058aafe04e9ddf73eb8929e98359d9a9c1ac97.tar.gz eclipse.platform.swt-51058aafe04e9ddf73eb8929e98359d9a9c1ac97.tar.xz eclipse.platform.swt-51058aafe04e9ddf73eb8929e98359d9a9c1ac97.zip |
Bug 538377 - Java crash after
org.eclipse.swt.internal.cocoa.NSApplication.setDelegate on macos 10.14
mojave with touch bar
Change-Id: I1581bad23de972009bf5308bf66a8ebeef03c040
(cherry picked from commit 6b498d085fe2e1e0f03402782ee7c8203d9d2202)
(cherry picked from commit 8f398cb6f40bc02560ea6fafa9cdc59cb60271e7)
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java | 18 |
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 5a0c9e1fda..3b16810a54 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, 2016 IBM Corporation and others. + * Copyright (c) 2000, 2018 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -901,7 +901,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, "@:"); @@ -914,7 +927,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); |