Skip to content
This repository has been archived by the owner on Dec 12, 2022. It is now read-only.

Commit

Permalink
fix: prevent possible memory leak (#1102) (#1132)
Browse files Browse the repository at this point in the history
Prevent possible memory leak when e.g. Grid is removed from layout as data provider listener is not explicitly removed.

Co-authored-by: Tatu Lund <tatu@vaadin.com>
  • Loading branch information
tomivirkki and TatuLund authored Oct 5, 2020
1 parent 3e8d07f commit edef209
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import com.vaadin.flow.component.ComponentEvent;
import com.vaadin.flow.component.ComponentEventListener;
import com.vaadin.flow.component.ComponentUtil;
import com.vaadin.flow.component.DetachEvent;
import com.vaadin.flow.component.Focusable;
import com.vaadin.flow.component.HasElement;
import com.vaadin.flow.component.HasSize;
Expand Down Expand Up @@ -3011,6 +3012,18 @@ public void sort(List<GridSortOrder<T>> order) {
protected void onAttach(AttachEvent attachEvent) {
super.onAttach(attachEvent);
updateClientSideSorterIndicators(sortOrder);
if (getDataProvider() != null && dataProviderChangeRegistration == null) {
handleDataProviderChange(getDataProvider());
}
}

@Override
protected void onDetach(DetachEvent detachEvent) {
if (dataProviderChangeRegistration != null) {
dataProviderChangeRegistration.remove();
dataProviderChangeRegistration = null;
}
super.onDetach(detachEvent);
}

private void setSortOrder(List<GridSortOrder<T>> order,
Expand Down

0 comments on commit edef209

Please # to comment.