]> source.dussan.org Git - vaadin-framework.git/commitdiff
fixes for #1584 (untested)
authorMatti Tahvonen <matti.tahvonen@itmill.com>
Tue, 22 Apr 2008 11:47:29 +0000 (11:47 +0000)
committerMatti Tahvonen <matti.tahvonen@itmill.com>
Tue, 22 Apr 2008 11:47:29 +0000 (11:47 +0000)
svn changeset:4204/svn branch:trunk

src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java

index 8c5a44f0ef17340baf55dddcca566309f8faa1e0..281ee45a2355d2c1f380803d0862b32d00547dcf 100644 (file)
@@ -292,16 +292,27 @@ public class CommunicationManager implements Paintable.RepaintRequestListener {
                 }
                 if (paintables != null) {
 
-                    // Sorts the Paintable list so that parents
-                    // are always painted before children
+                    // We need to avoid painting children before parent.
+                    // This is ensured by ordering list by depth in component
+                    // tree
                     Collections.sort(paintables, new Comparator() {
                         public int compare(Object o1, Object o2) {
-                            final Component c1 = (Component) o1;
-                            final Component c2 = (Component) o2;
-                            if (isChildOf(c1, c2)) {
+                            Component c1 = (Component) o1;
+                            Component c2 = (Component) o2;
+                            int d1 = 0;
+                            while (c1.getParent() != null) {
+                                d1++;
+                                c1 = c1.getParent();
+                            }
+                            int d2 = 0;
+                            while (c2.getParent() != null) {
+                                d2++;
+                                c2 = c2.getParent();
+                            }
+                            if (d1 < d2) {
                                 return -1;
                             }
-                            if (isChildOf(c2, c1)) {
+                            if (d1 > d2) {
                                 return 1;
                             }
                             return 0;