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)
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.
  • Loading branch information
TatuLund authored Sep 24, 2020
1 parent 3e466a4 commit f5c5060
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,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 @@ -3149,6 +3150,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 f5c5060

Please # to comment.