Avoid memory leak

Delete previous associated listeners so the previous FormBinder and
associated objects can be reclaimed by GC.

FEA: ItEr69S04BugFixing
This commit is contained in:
Óscar González Fernández 2011-01-31 16:08:48 +01:00
parent 0563524f4a
commit c9f038974f

View file

@ -285,7 +285,8 @@ public class FormBinder {
}
private void onChangeEnableApply(InputElement inputElement) {
inputElement.addEventListener(Events.ON_CHANGE, onChangeEnableApply);
Util.ensureUniqueListener(inputElement, Events.ON_CHANGE,
onChangeEnableApply);
}
public void setWorkableDays(Intbox duration,
@ -311,28 +312,28 @@ public class FormBinder {
this.labelTaskStart = labelTaskStart;
this.labelTaskEnd = labelTaskEnd;
initializeDateAndDurationFieldsFromTaskOriginalValues();
taskWorkableDays.addEventListener(Events.ON_CHANGE,
Util.ensureUniqueListener(taskWorkableDays, Events.ON_CHANGE,
new EventListener() {
@Override
public void onEvent(Event event) throws Exception {
Task task = getTask();
Integer workableDays = taskWorkableDays.getValue();
if (allocationRowsHandler.isForwardsAllocation()) {
LocalDate newEndDate = task
.calculateEndGivenWorkableDays(workableDays);
taskPropertiesController
.updateTaskEndDate(newEndDate);
showValueOfDateOn(labelTaskEnd, newEndDate);
} else {
LocalDate newStart = task
.calculateStartGivenWorkableDays(workableDays);
taskPropertiesController
.updateTaskStartDate(newStart);
showValueOfDateOn(labelTaskStart, newStart);
}
}
});
@Override
public void onEvent(Event event) throws Exception {
Task task = getTask();
Integer workableDays = taskWorkableDays.getValue();
if (allocationRowsHandler.isForwardsAllocation()) {
LocalDate newEndDate = task
.calculateEndGivenWorkableDays(workableDays);
taskPropertiesController
.updateTaskEndDate(newEndDate);
showValueOfDateOn(labelTaskEnd, newEndDate);
} else {
LocalDate newStart = task
.calculateStartGivenWorkableDays(workableDays);
taskPropertiesController
.updateTaskStartDate(newStart);
showValueOfDateOn(labelTaskStart, newStart);
}
}
});
applyDisabledRules();
onChangeEnableApply(taskWorkableDays);
}
@ -556,7 +557,8 @@ public class FormBinder {
FormBinder.this.applyButton.setDisabled(true);
}
};
this.applyButton.addEventListener(Events.ON_CLICK, applyButtonListener);
Util.ensureUniqueListener(this.applyButton, Events.ON_CLICK,
applyButtonListener);
}
public int getAssignedHours() {