Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLakshmi Shanmugam2018-09-03 08:10:15 +0000
committerLakshmi Shanmugam2018-09-04 11:19:49 +0000
commit439ef5aad0500b5642b2b29398277de1e0fa3a3b (patch)
tree42e873a358a4638428cc953e9dc8a207fe5e21d1
parent2d12fe6472ac5751186b210db3163ac70785ec1e (diff)
downloadeclipse.platform.swt-439ef5aad0500b5642b2b29398277de1e0fa3a3b.tar.gz
eclipse.platform.swt-439ef5aad0500b5642b2b29398277de1e0fa3a3b.tar.xz
eclipse.platform.swt-439ef5aad0500b5642b2b29398277de1e0fa3a3b.zip
Bug 536588: [Cocoa][GTK] GC.copyArea() doesn't work for StyledText
Though the paint event sent by GC.copyArea() is unexpected, we can't ignore it. It is required for GC.copyArea to work with custom controls. The fix is to prevent recursive calls to cacheDisplayInRect_toBitmapImageRep. Change-Id: I7ee99d3dd6a2824010ea3a1fbc4c36c2a09e1763 (cherry picked from commit 36bd428f1c9a3c2dfa7b0d8eab63495b292687e1)
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java15
1 files changed, 7 insertions, 8 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java
index bc09cd7d7c..5f0d5105f8 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java
@@ -72,7 +72,7 @@ public abstract class Control extends Widget implements Drawable {
NSBezierPath regionPath;
long /*int*/ visibleRgn;
Accessible accessible;
- boolean ignorePaint;
+ boolean inCacheDisplayInRect;
boolean touchEnabled;
final static int CLIPPING = 1 << 10;
@@ -1263,7 +1263,6 @@ boolean drawsBackground() {
@Override
void drawWidget (long /*int*/ id, NSGraphicsContext context, NSRect rect) {
- if (ignorePaint) return;
if (id != paintView().id) return;
if (!hooks (SWT.Paint) && !filters (SWT.Paint)) return;
@@ -3973,14 +3972,14 @@ void cacheDisplayInRect_toBitmapImageRep (long id, long sel, NSRect rect, long r
* When a GC is created with a control as the Drawable and GC.copyArea() is
* called, a SWT.Paint event will be sent, unexpectedly. This happens because
* NSView.cacheDisplayInRect() calls drawRect() which causes a SWT.Paint event
- * to be sent. The fix is to ignore this paint event and prevent SWT from
- * sending it to the clients.
- * In the callback, set the ignorePaint flag, then call the Cocoa
- * implementation of cacheDisplayInRect_toBitmapImageRep(), then reset the ignorePaint flag.
+ * to be sent. This leads to recursion if GC.copyArea() is called inside the PaintListener.
+ *
+ * The fix is to prevent recursive calls to cacheDisplayInRect_toBitmapImageRep.
*/
- ignorePaint = true;
+ if (inCacheDisplayInRect) return;
+ inCacheDisplayInRect = true;
super.cacheDisplayInRect_toBitmapImageRep(id, sel, rect, rep);
- ignorePaint = false;
+ inCacheDisplayInRect = false;
}
/**

Back to the top