]> source.dussan.org Git - vaadin-framework.git/commitdiff
getParent() shouldn't throw npe when widget's parent is null
authorLeif Åstrand <leif@vaadin.com>
Tue, 7 Feb 2012 12:39:40 +0000 (14:39 +0200)
committerLeif Åstrand <leif@vaadin.com>
Tue, 7 Feb 2012 12:39:40 +0000 (14:39 +0200)
src/com/vaadin/terminal/gwt/client/ui/VAbstractPaintableWidget.java

index 474e9c416d4f66135433b7fc6f14a3de534882b2..9747deacd1b3b46ac9bad940a171f93efc6cdcaa 100644 (file)
@@ -15,7 +15,7 @@ public abstract class VAbstractPaintableWidget implements VPaintableWidget {
     private ApplicationConnection connection;
     private String id;
     private VPaintableWidgetContainer parent;
-    
+
     /* State variables */
     private boolean enabled = true;
 
@@ -86,21 +86,24 @@ public abstract class VAbstractPaintableWidget implements VPaintableWidget {
     }
 
     public VPaintableWidgetContainer getParent() {
-        if (parent != null)
+        if (parent != null) {
             return parent;
-        
+        }
+
         // FIXME: Hierarchy should be set by framework instead of looked up here
         VPaintableMap paintableMap = VPaintableMap.get(getConnection());
 
         Widget w = getWidgetForPaintable();
-        while (w != null) {
+        while (true) {
             w = w.getParent();
+            if (w == null) {
+                return null;
+            }
             if (paintableMap.isPaintable(w)) {
-                parent = (VPaintableWidgetContainer) paintableMap.getPaintable(w);
+                parent = (VPaintableWidgetContainer) paintableMap
+                        .getPaintable(w);
                 return parent;
             }
         }
-
-        return null;
     }
 }