Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTill Brychcy2016-09-29 20:53:41 +0000
committerLakshmi Shanmugam2017-12-08 11:38:29 +0000
commit05ad9a7ee80cc8b6c65d65863a1226f3a6745c11 (patch)
tree2bb7a68ff0c37b08c4c68cac44f054795c5b061d
parent5cb45182e43826f602363636f4eaaa93626ce665 (diff)
downloadeclipse.platform.swt-05ad9a7ee80cc8b6c65d65863a1226f3a6745c11.tar.gz
eclipse.platform.swt-05ad9a7ee80cc8b6c65d65863a1226f3a6745c11.tar.xz
eclipse.platform.swt-05ad9a7ee80cc8b6c65d65863a1226f3a6745c11.zip
Bug 502711 - [Cocoa] crashes on „macOS Sierra“ related to NSCopyBits
Replaced the calls to deprecated method NSCopyBits with NSView.scrollRect() in GC.copyArea and Canvas.scroll. Removed the native code for NSCopyBits. Disable generation of code for deprecated method NSCopyBits as it is not used anymore Change-Id: I206c76cd6af9230857967fb23641f0773f90e5de Signed-off-by: Till Brychcy <register.eclipse@brychcy.de> Signed-off-by: Lakshmi Shanmugam <lshanmug@in.ibm.com> Signed-off-by: Arun Thondapu <arunkumar.thondapu@in.ibm.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os.c47
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.c6
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.h6
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras11
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSView.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java13
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/GC.java5
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Canvas.java5
8 files changed, 64 insertions, 33 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os.c b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os.c
index adcb6f8f79..caf1ab405b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os.c
@@ -4555,23 +4555,6 @@ JNIEXPORT jintLong JNICALL OS_NATIVE(NSCalibratedRGBColorSpace)
}
#endif
-#ifndef NO_NSCopyBits
-JNIEXPORT void JNICALL OS_NATIVE(NSCopyBits)
- (JNIEnv *env, jclass that, jintLong arg0, jobject arg1, jobject arg2)
-{
- NSRect _arg1, *lparg1=NULL;
- NSPoint _arg2, *lparg2=NULL;
- OS_NATIVE_ENTER(env, that, NSCopyBits_FUNC);
- if (arg1) if ((lparg1 = getNSRectFields(env, arg1, &_arg1)) == NULL) goto fail;
- if (arg2) if ((lparg2 = getNSPointFields(env, arg2, &_arg2)) == NULL) goto fail;
- NSCopyBits((NSInteger)arg0, *lparg1, *lparg2);
-fail:
- if (arg2 && lparg2) setNSPointFields(env, arg2, lparg2);
- if (arg1 && lparg1) setNSRectFields(env, arg1, lparg1);
- OS_NATIVE_EXIT(env, that, NSCopyBits_FUNC);
-}
-#endif
-
#ifndef NO_NSCountWindows
JNIEXPORT void JNICALL OS_NATIVE(NSCountWindows)
(JNIEnv *env, jclass that, jintLongArray arg0)
@@ -8469,6 +8452,36 @@ fail:
}
#endif
+#if (!defined(NO_objc_1msgSend__IILorg_eclipse_swt_internal_cocoa_NSRect_2Lorg_eclipse_swt_internal_cocoa_NSSize_2) && !defined(JNI64)) || (!defined(NO_objc_1msgSend__JJLorg_eclipse_swt_internal_cocoa_NSRect_2Lorg_eclipse_swt_internal_cocoa_NSSize_2) && defined(JNI64))
+#ifndef JNI64
+JNIEXPORT jintLong JNICALL OS_NATIVE(objc_1msgSend__IILorg_eclipse_swt_internal_cocoa_NSRect_2Lorg_eclipse_swt_internal_cocoa_NSSize_2)(JNIEnv *env, jclass that, jintLong arg0, jintLong arg1, jobject arg2, jobject arg3)
+#else
+JNIEXPORT jintLong JNICALL OS_NATIVE(objc_1msgSend__JJLorg_eclipse_swt_internal_cocoa_NSRect_2Lorg_eclipse_swt_internal_cocoa_NSSize_2)(JNIEnv *env, jclass that, jintLong arg0, jintLong arg1, jobject arg2, jobject arg3)
+#endif
+{
+ NSRect _arg2, *lparg2=NULL;
+ NSSize _arg3, *lparg3=NULL;
+ jintLong rc = 0;
+#ifndef JNI64
+ OS_NATIVE_ENTER(env, that, objc_1msgSend__IILorg_eclipse_swt_internal_cocoa_NSRect_2Lorg_eclipse_swt_internal_cocoa_NSSize_2_FUNC);
+#else
+ OS_NATIVE_ENTER(env, that, objc_1msgSend__JJLorg_eclipse_swt_internal_cocoa_NSRect_2Lorg_eclipse_swt_internal_cocoa_NSSize_2_FUNC);
+#endif
+ if (arg2) if ((lparg2 = getNSRectFields(env, arg2, &_arg2)) == NULL) goto fail;
+ if (arg3) if ((lparg3 = getNSSizeFields(env, arg3, &_arg3)) == NULL) goto fail;
+ rc = (jintLong)((jintLong (*)(jintLong, jintLong, NSRect, NSSize))objc_msgSend)(arg0, arg1, *lparg2, *lparg3);
+fail:
+ if (arg3 && lparg3) setNSSizeFields(env, arg3, lparg3);
+ if (arg2 && lparg2) setNSRectFields(env, arg2, lparg2);
+#ifndef JNI64
+ OS_NATIVE_EXIT(env, that, objc_1msgSend__IILorg_eclipse_swt_internal_cocoa_NSRect_2Lorg_eclipse_swt_internal_cocoa_NSSize_2_FUNC);
+#else
+ OS_NATIVE_EXIT(env, that, objc_1msgSend__JJLorg_eclipse_swt_internal_cocoa_NSRect_2Lorg_eclipse_swt_internal_cocoa_NSSize_2_FUNC);
+#endif
+ return rc;
+}
+#endif
+
#if (!defined(NO_objc_1msgSend__IILorg_eclipse_swt_internal_cocoa_NSRect_2Z) && !defined(JNI64)) || (!defined(NO_objc_1msgSend__JJLorg_eclipse_swt_internal_cocoa_NSRect_2Z) && defined(JNI64))
#ifndef JNI64
JNIEXPORT jintLong JNICALL OS_NATIVE(objc_1msgSend__IILorg_eclipse_swt_internal_cocoa_NSRect_2Z)(JNIEnv *env, jclass that, jintLong arg0, jintLong arg1, jobject arg2, jboolean arg3)
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.c b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.c
index 0bea38227f..a7572aac02 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.c
@@ -340,7 +340,6 @@ char * OS_nativeFunctionNames[] = {
"NSBeep",
"NSBitsPerPixelFromDepth",
"NSCalibratedRGBColorSpace",
- "NSCopyBits",
"NSCountWindows",
"NSCursorAttributeName",
"NSDefaultRunLoopMode",
@@ -872,6 +871,11 @@ char * OS_nativeFunctionNames[] = {
"objc_1msgSend__JJLorg_eclipse_swt_internal_cocoa_NSRect_2Lorg_eclipse_swt_internal_cocoa_NSRect_2JD",
#endif
#ifndef JNI64
+ "objc_1msgSend__IILorg_eclipse_swt_internal_cocoa_NSRect_2Lorg_eclipse_swt_internal_cocoa_NSSize_2",
+#else
+ "objc_1msgSend__JJLorg_eclipse_swt_internal_cocoa_NSRect_2Lorg_eclipse_swt_internal_cocoa_NSSize_2",
+#endif
+#ifndef JNI64
"objc_1msgSend__IILorg_eclipse_swt_internal_cocoa_NSRect_2Z",
#else
"objc_1msgSend__JJLorg_eclipse_swt_internal_cocoa_NSRect_2Z",
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.h b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.h
index dabf7e2a72..d1788297c5 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.h
@@ -350,7 +350,6 @@ typedef enum {
NSBeep_FUNC,
NSBitsPerPixelFromDepth_FUNC,
NSCalibratedRGBColorSpace_FUNC,
- NSCopyBits_FUNC,
NSCountWindows_FUNC,
NSCursorAttributeName_FUNC,
NSDefaultRunLoopMode_FUNC,
@@ -882,6 +881,11 @@ typedef enum {
objc_1msgSend__JJLorg_eclipse_swt_internal_cocoa_NSRect_2Lorg_eclipse_swt_internal_cocoa_NSRect_2JD_FUNC,
#endif
#ifndef JNI64
+ objc_1msgSend__IILorg_eclipse_swt_internal_cocoa_NSRect_2Lorg_eclipse_swt_internal_cocoa_NSSize_2_FUNC,
+#else
+ objc_1msgSend__JJLorg_eclipse_swt_internal_cocoa_NSRect_2Lorg_eclipse_swt_internal_cocoa_NSSize_2_FUNC,
+#endif
+#ifndef JNI64
objc_1msgSend__IILorg_eclipse_swt_internal_cocoa_NSRect_2Z_FUNC,
#else
objc_1msgSend__JJLorg_eclipse_swt_internal_cocoa_NSRect_2Z_FUNC,
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras
index 4e3933d433..4c31306652 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras
@@ -4106,6 +4106,11 @@
<arg swt_gen="true"></arg>
<retval swt_gen="true"></retval>
</method>
+ <method selector="scrollRect:by:" swt_gen="true">
+ <arg swt_gen="true"></arg>
+ <arg swt_gen="true"></arg>
+ <retval swt_gen="true"></retval>
+ </method>
<method selector="scrollRectToVisible:" swt_gen="true">
<arg swt_gen="true"></arg>
<retval swt_gen="true"></retval>
@@ -5038,12 +5043,6 @@
<arg swt_gen="true"></arg>
<retval swt_gen="true"></retval>
</function>
- <function name="NSCopyBits" swt_gen="true">
- <arg swt_gen="true"></arg>
- <arg swt_gen="true"></arg>
- <arg swt_gen="true"></arg>
- <retval></retval>
- </function>
<function name="NSCountWindows" swt_gen="true">
<arg swt_gen="true" swt_java_type="int[]" swt_java_type64="long[]"></arg>
<retval></retval>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSView.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSView.java
index 61efe09316..2aa630582e 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSView.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSView.java
@@ -256,6 +256,10 @@ public void scrollPoint(NSPoint aPoint) {
OS.objc_msgSend(this.id, OS.sel_scrollPoint_, aPoint);
}
+public void scrollRect(NSRect aRect, NSSize delta) {
+ OS.objc_msgSend(this.id, OS.sel_scrollRect_by_, aRect, delta);
+}
+
public boolean scrollRectToVisible(NSRect aRect) {
return OS.objc_msgSend_bool(this.id, OS.sel_scrollRectToVisible_, aRect);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java
index 131b24253d..d322f62ec5 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java
@@ -1794,6 +1794,7 @@ public static final long /*int*/ sel_scrollClipView_toPoint_ = sel_registerName(
public static final long /*int*/ sel_scrollColumnToVisible_ = sel_registerName("scrollColumnToVisible:");
public static final long /*int*/ sel_scrollPoint_ = sel_registerName("scrollPoint:");
public static final long /*int*/ sel_scrollRangeToVisible_ = sel_registerName("scrollRangeToVisible:");
+public static final long /*int*/ sel_scrollRect_by_ = sel_registerName("scrollRect:by:");
public static final long /*int*/ sel_scrollRectToVisible_ = sel_registerName("scrollRectToVisible:");
public static final long /*int*/ sel_scrollRowToVisible_ = sel_registerName("scrollRowToVisible:");
public static final long /*int*/ sel_scrollToPoint_ = sel_registerName("scrollToPoint:");
@@ -3257,12 +3258,6 @@ public static final native void NSBeep();
*/
public static final native long /*int*/ NSBitsPerPixelFromDepth(int depth);
/**
- * @param srcGState cast=(NSInteger)
- * @param srcRect flags=struct
- * @param destPoint flags=struct
- */
-public static final native void NSCopyBits(long /*int*/ srcGState, NSRect srcRect, NSPoint destPoint);
-/**
* @param count cast=(NSInteger*)
*/
public static final native void NSCountWindows(long[] /*int[]*/ count);
@@ -3997,6 +3992,12 @@ public static final native long /*int*/ objc_msgSend(long /*int*/ id, long /*int
/**
* @method flags=cast
* @param arg0 flags=struct
+ * @param arg1 flags=struct
+ */
+public static final native long /*int*/ objc_msgSend(long /*int*/ id, long /*int*/ sel, NSRect arg0, NSSize arg1);
+/**
+ * @method flags=cast
+ * @param arg0 flags=struct
*/
public static final native long /*int*/ objc_msgSend(long /*int*/ id, long /*int*/ sel, NSRect arg0, boolean arg1);
/**
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/GC.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/GC.java
index 1d2870a909..802653a116 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/GC.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/GC.java
@@ -629,7 +629,10 @@ public void copyArea(int srcX, int srcY, int width, int height, int destX, int d
dest.y = destY;
view.lockFocus();
- OS.NSCopyBits(0, damage , dest);
+ NSSize delta = new NSSize();
+ delta.width = deltaX;
+ delta.height = deltaY;
+ view.scrollRect(damage, delta);
view.unlockFocus();
if (paint) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Canvas.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Canvas.java
index 27f048d200..819ff40749 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Canvas.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Canvas.java
@@ -425,7 +425,10 @@ public void scroll (int destX, int destY, int x, int y, int width, int height, b
dest.y = destY;
view.lockFocus();
- OS.NSCopyBits(0, damage , dest);
+ NSSize delta = new NSSize();
+ delta.width = deltaX;
+ delta.height = deltaY;
+ view.scrollRect(damage, delta);
view.unlockFocus();
boolean disjoint = (destX + width < x) || (x + width < destX) || (destY + height < y) || (y + height < destY);

Back to the top