CopyableLabel: Fix potential leak for unshown widgets
If the label is never attached to the DOM the handler was leaking the reference to the widget and its internal DOM. Defer registering for dialog events until the widget is in the DOM and a flash movie has also been created. Change-Id: I9ca815743a8e69dc6a1a29c9c8cdb5f1400f6804
This commit is contained in:
parent
dc3ce8e2dd
commit
4a3b1e0a59
@ -160,19 +160,22 @@ public class CopyableLabel extends Composite implements HasText {
|
||||
DOM.removeChild(getElement(), swf);
|
||||
}
|
||||
DOM.appendChild(getElement(), swf = SafeHtml.parse(h));
|
||||
initHideHandler();
|
||||
}
|
||||
}
|
||||
|
||||
if (hideHandler == null) {
|
||||
hideHandler =
|
||||
UserAgent.addDialogVisibleHandler(new DialogVisibleHandler() {
|
||||
@Override
|
||||
public void onDialogVisible(DialogVisibleEvent event) {
|
||||
swf.getStyle().setVisibility(
|
||||
event.isVisible()
|
||||
? Style.Visibility.HIDDEN
|
||||
: Style.Visibility.VISIBLE);
|
||||
}
|
||||
});
|
||||
}
|
||||
private void initHideHandler() {
|
||||
if (hideHandler == null && swf != null && isAttached()) {
|
||||
hideHandler =
|
||||
UserAgent.addDialogVisibleHandler(new DialogVisibleHandler() {
|
||||
@Override
|
||||
public void onDialogVisible(DialogVisibleEvent event) {
|
||||
swf.getStyle().setVisibility(
|
||||
event.isVisible()
|
||||
? Style.Visibility.HIDDEN
|
||||
: Style.Visibility.VISIBLE);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -195,7 +198,12 @@ public class CopyableLabel extends Composite implements HasText {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUnload() {
|
||||
protected void onLoad() {
|
||||
initHideHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onUnload() {
|
||||
if (hideHandler != null) {
|
||||
hideHandler.removeHandler();
|
||||
hideHandler = null;
|
||||
|
Loading…
Reference in New Issue
Block a user