Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTill Brychcy2016-09-29 20:53:41 +0000
committerLakshmi Shanmugam2017-03-23 12:09:26 +0000
commit528fcab722ccdaa43c8d596494e2f2799889db3c (patch)
tree58fa1a96f473d331b6f06f2daeb63b15f890779d /bundles/org.eclipse.swt
parent010d9d278b66159e1bb8026b19814c336766fc4f (diff)
downloadeclipse.platform.swt-528fcab722ccdaa43c8d596494e2f2799889db3c.tar.gz
eclipse.platform.swt-528fcab722ccdaa43c8d596494e2f2799889db3c.tar.xz
eclipse.platform.swt-528fcab722ccdaa43c8d596494e2f2799889db3c.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. Change-Id: I206c76cd6af9230857967fb23641f0773f90e5de Signed-off-by: Till Brychcy <register.eclipse@brychcy.de> Signed-off-by: Lakshmi Shanmugam <lshanmug@in.ibm.com>
Diffstat (limited to 'bundles/org.eclipse.swt')
-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.extras5
-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, 27 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 46bb4a1a7f..f7f81d3a03 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
@@ -4558,23 +4558,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)
@@ -8484,6 +8467,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 9df0f95c8e..985d265455 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
@@ -343,7 +343,6 @@ char * OS_nativeFunctionNames[] = {
"NSBeep",
"NSBitsPerPixelFromDepth",
"NSCalibratedRGBColorSpace",
- "NSCopyBits",
"NSCountWindows",
"NSCursorAttributeName",
"NSDefaultRunLoopMode",
@@ -876,6 +875,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 92513cec10..1d72006f83 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
@@ -353,7 +353,6 @@ typedef enum {
NSBeep_FUNC,
NSBitsPerPixelFromDepth_FUNC,
NSCalibratedRGBColorSpace_FUNC,
- NSCopyBits_FUNC,
NSCountWindows_FUNC,
NSCursorAttributeName_FUNC,
NSDefaultRunLoopMode_FUNC,
@@ -886,6 +885,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 57c24c7599..7530b1df2a 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>
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 5c4fb6c633..50ac015759 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 77d74f6ec7..94a6831620 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:");
@@ -3260,12 +3261,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);
@@ -4000,6 +3995,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 094a0ba977..697b4196bc 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