diff options
author | Leif Åstrand <leif@vaadin.com> | 2012-08-10 11:30:24 +0300 |
---|---|---|
committer | Leif Åstrand <leif@vaadin.com> | 2012-08-10 11:30:24 +0300 |
commit | 3c1e9fb02c8fc376c16f9069a58f17227f7f58de (patch) | |
tree | 79eee54eabc954a039b783e41052e193f8cadcbe /src/com | |
parent | 454f44738b20b22aeeb327523f1306b46d3cbef6 (diff) | |
download | vaadin-framework-3c1e9fb02c8fc376c16f9069a58f17227f7f58de.tar.gz vaadin-framework-3c1e9fb02c8fc376c16f9069a58f17227f7f58de.zip |
Allow detaching Extension once (#9282)
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/vaadin/terminal/gwt/client/extensions/AbstractExtensionConnector.java | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/extensions/AbstractExtensionConnector.java b/src/com/vaadin/terminal/gwt/client/extensions/AbstractExtensionConnector.java index bcefcf05cb..408f03f6cb 100644 --- a/src/com/vaadin/terminal/gwt/client/extensions/AbstractExtensionConnector.java +++ b/src/com/vaadin/terminal/gwt/client/extensions/AbstractExtensionConnector.java @@ -8,17 +8,26 @@ import com.vaadin.terminal.gwt.client.ServerConnector; import com.vaadin.terminal.gwt.client.ui.AbstractConnector; public abstract class AbstractExtensionConnector extends AbstractConnector { + boolean hasBeenAttached = false; + @Override public void setParent(ServerConnector parent) { ServerConnector oldParent = getParent(); - if (oldParent != null && oldParent != parent) { + if (oldParent == parent) { + // Nothing to do + return; + } + if (hasBeenAttached && parent != null) { throw new IllegalStateException( "An extension can not be moved from one parent to another."); } super.setParent(parent); - extend(parent); + if (parent != null) { + extend(parent); + hasBeenAttached = true; + } } protected void extend(ServerConnector target) { |