diff options
author | Tobse <1190109+TobseF@users.noreply.github.com> | 2019-03-27 18:59:08 +0100 |
---|---|---|
committer | Pekka Hyvönen <pekka@vaadin.com> | 2019-03-27 19:59:08 +0200 |
commit | 7cd94ce0b02bb4ecd7826283d3928e3a66e39301 (patch) | |
tree | c82317058996420fb7c3f00f64f6c2135d977eed /compatibility-client | |
parent | 51b64cc579c302b693aecfbf91726fa45dc08b47 (diff) | |
download | vaadin-framework-7cd94ce0b02bb4ecd7826283d3928e3a66e39301.tar.gz vaadin-framework-7cd94ce0b02bb4ecd7826283d3928e3a66e39301.zip |
Fix NPE in v7 compatibility Grid during datasource rebind (#11473)
Add DataChangeHandler removal in v7 Grid just as in v8 Grid.
Adding tests to the fix to verify, that NPE is not thrown.
Diffstat (limited to 'compatibility-client')
-rwxr-xr-x | compatibility-client/src/main/java/com/vaadin/v7/client/widgets/Grid.java | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/widgets/Grid.java b/compatibility-client/src/main/java/com/vaadin/v7/client/widgets/Grid.java index 631f3bdb65..1d2f88f570 100755 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/widgets/Grid.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/widgets/Grid.java @@ -4152,6 +4152,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>, * on initialization, but not after that. */ private DataSource<T> dataSource; + private Registration changeHandler; /** * Currently available row range in DataSource. @@ -7023,12 +7024,13 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>, selectionModel.reset(); - if (this.dataSource != null) { - this.dataSource.addDataChangeHandler((DataChangeHandler) null); + if (changeHandler != null) { + changeHandler.remove(); + changeHandler = null; } this.dataSource = dataSource; - dataSource.addDataChangeHandler(new DataChangeHandler() { + changeHandler = dataSource.addDataChangeHandler(new DataChangeHandler() { @Override public void dataUpdated(int firstIndex, int numberOfItems) { escalator.getBody().refreshRows(firstIndex, numberOfItems); |