From b6bbe94e9c6fe536a835775fab2bfaf56fb6f1d2 Mon Sep 17 00:00:00 2001 From: leewyatt Date: Fri, 10 May 2024 01:43:46 +0900 Subject: [PATCH] Fix bug in supportedOperations property initialization This commit addresses a critical bug in the getSupportedOperations method where modifications to the returned list did not affect the underlying supportedOperations property. Previously, if the supportedOperations property was not initialized, getSupportedOperations would return a new ObservableList that was not bound to the supportedOperations property, leading to discrepancies in data handling. --- .../java/com/dlsc/gemsfx/util/ResizingBehaviour.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/gemsfx/src/main/java/com/dlsc/gemsfx/util/ResizingBehaviour.java b/gemsfx/src/main/java/com/dlsc/gemsfx/util/ResizingBehaviour.java index 1ec96b0e..5421fa48 100644 --- a/gemsfx/src/main/java/com/dlsc/gemsfx/util/ResizingBehaviour.java +++ b/gemsfx/src/main/java/com/dlsc/gemsfx/util/ResizingBehaviour.java @@ -2,6 +2,7 @@ import javafx.beans.property.BooleanProperty; import javafx.beans.property.DoubleProperty; +import javafx.beans.property.ListProperty; import javafx.beans.property.ObjectProperty; import javafx.beans.property.SimpleBooleanProperty; import javafx.beans.property.SimpleDoubleProperty; @@ -373,7 +374,7 @@ public final void setResizable(boolean resizable) { resizableProperty().set(resizable); } - private SimpleListProperty supportedOperations; + private final ListProperty supportedOperations = new SimpleListProperty<>(this, "supportedOperations", FXCollections.observableArrayList(Operation.values())); /** * The list of supported operations for resizing the region. @@ -382,15 +383,12 @@ public final void setResizable(boolean resizable) { * * @return the list of supported operations */ - public final SimpleListProperty supportedOperationsProperty() { - if (supportedOperations == null) { - supportedOperations = new SimpleListProperty<>(this, "supportedOperations", FXCollections.observableArrayList(Operation.values())); - } + public final ListProperty supportedOperationsProperty() { return supportedOperations; } public final ObservableList getSupportedOperations() { - return supportedOperations == null ? FXCollections.observableArrayList(Operation.values()) : supportedOperations.get(); + return supportedOperations.get(); } public final void setSupportedOperations(ObservableList supportedOperations) {