From 71015235847853b1817e047e5540b743ee7edbd8 Mon Sep 17 00:00:00 2001 From: kske Date: Sat, 25 Dec 2021 21:57:25 +0200 Subject: [PATCH] Update properties on wrapper creation, fix NPE --- .../java/dev/kske/undoredo/javafx/ChangeManagerWrapper.java | 1 + .../java/dev/kske/undoredo/javafx/ObservableChangeManager.java | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/javafx/src/main/java/dev/kske/undoredo/javafx/ChangeManagerWrapper.java b/javafx/src/main/java/dev/kske/undoredo/javafx/ChangeManagerWrapper.java index 945477d..0abd163 100644 --- a/javafx/src/main/java/dev/kske/undoredo/javafx/ChangeManagerWrapper.java +++ b/javafx/src/main/java/dev/kske/undoredo/javafx/ChangeManagerWrapper.java @@ -47,6 +47,7 @@ public class ChangeManagerWrapper> */ public ChangeManagerWrapper(M manager) { this.manager = manager; + updateProperties(); } @Override diff --git a/javafx/src/main/java/dev/kske/undoredo/javafx/ObservableChangeManager.java b/javafx/src/main/java/dev/kske/undoredo/javafx/ObservableChangeManager.java index 2908589..28ffebe 100644 --- a/javafx/src/main/java/dev/kske/undoredo/javafx/ObservableChangeManager.java +++ b/javafx/src/main/java/dev/kske/undoredo/javafx/ObservableChangeManager.java @@ -21,7 +21,7 @@ public interface ObservableChangeManager extends ChangeManager @Override default Optional getLastChange() { - return Optional.of(lastChangeProperty().get()); + return Optional.ofNullable(lastChangeProperty().get()); } ReadOnlyBooleanProperty atMarkedChangeProperty();