Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLakshmi Shanmugam2018-09-03 08:10:15 +0000
committerLakshmi Shanmugam2018-09-04 08:23:44 +0000
commit36bd428f1c9a3c2dfa7b0d8eab63495b292687e1 (patch)
tree975e6dd7cb1c50dddfbfef83f2f0a9982a007ca2
parent9b93087da31a1de6cbaeb965ceec89602ebb0d9e (diff)
downloadeclipse.platform.swt-36bd428f1c9a3c2dfa7b0d8eab63495b292687e1.tar.gz
eclipse.platform.swt-36bd428f1c9a3c2dfa7b0d8eab63495b292687e1.tar.xz
eclipse.platform.swt-36bd428f1c9a3c2dfa7b0d8eab63495b292687e1.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
-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