Bug 407555 - StackOverflowError in SWT widgets on Mac OS
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 7500c9f..4452ba5 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
@@ -3979,6 +3979,10 @@
 			<arg swt_gen="true"></arg>
 			<retval swt_gen="true" swt_java_type="NSView"></retval>
 		</method>
+		<method selector="isDescendantOf:" swt_gen="true">
+			<arg swt_gen="true"></arg>
+			<retval swt_gen="true"></retval>
+		</method>
 		<method selector="isFlipped" swt_gen="true">
 			<retval swt_gen="true"></retval>
 		</method>
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 7dd64ab..853ff94 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
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2013 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
@@ -178,6 +178,10 @@
 	return result == this.id ? this : (result != 0 ? new NSView(result) : null);
 }
 
+public boolean isDescendantOf(NSView aView) {
+	return OS.objc_msgSend_bool(this.id, OS.sel_isDescendantOf_, aView != null ? aView.id : 0);
+}
+
 public boolean isFlipped() {
 	return OS.objc_msgSend_bool(this.id, OS.sel_isFlipped);
 }
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 dc3560e..83e395e 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
@@ -1438,6 +1438,7 @@
 public static final long /*int*/ sel_invalidateShadow = sel_registerName("invalidateShadow");
 public static final long /*int*/ sel_invert = sel_registerName("invert");
 public static final long /*int*/ sel_isActive = sel_registerName("isActive");
+public static final long /*int*/ sel_isDescendantOf_ = sel_registerName("isDescendantOf:");
 public static final long /*int*/ sel_isDocumentEdited = sel_registerName("isDocumentEdited");
 public static final long /*int*/ sel_isDrawingToScreen = sel_registerName("isDrawingToScreen");
 public static final long /*int*/ sel_isEmpty = sel_registerName("isEmpty");
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 946473f..d27ffa4 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
@@ -4915,7 +4915,12 @@
 
 void update (boolean all) {
 //	checkWidget();
-	if (display.isPainting.containsObject(view)) return;
+	NSArray isPainting = display.isPainting;
+	if (isPainting.containsObject(view)) return;
+	for (int i = 0, length = (int)/*64*/isPainting.count(); i < length; i++) {
+		NSView view = new NSView(isPainting.objectAtIndex(i));
+		if (view.isDescendantOf(this.view)) return;
+	}
 	if (isResizing()) return;
 	Shell shell = getShell();
 	NSWindow window = shell.deferFlushing && shell.scrolling ? view.window() : null;