}
private void cleanUp() {
RootPanel.get().remove(doubleLoadedImage);
final HandlerRegistration onLoadReg = onLoadHandlerRegistration;
final HandlerRegistration onErrorReg = onErrorHandlerRegistration;
// HACK(user): There is a bug in GWT which stops us from removing a listener in HOSTED
// mode inside the invoke context. Put the remove in a deferred command to avoid this
// error
ScheduleCommand.addCommand(new Scheduler.Task() {
public void execute() {
onLoadReg.removeHandler();
onErrorReg.removeHandler();
}
});
onLoadHandlerRegistration = null;
onErrorHandlerRegistration = null;