From e428cc711723547559160a7449cd33381f726a64 Mon Sep 17 00:00:00 2001 From: Haowei Wen Date: Wed, 1 Sep 2021 16:41:07 +0800 Subject: [PATCH] fix: check if property is bound before setting value of ReadWriteComposedProperty --- .../hmcl/util/javafx/ReadWriteComposedProperty.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/util/javafx/ReadWriteComposedProperty.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/util/javafx/ReadWriteComposedProperty.java index 9dd9246a2..60e2061f1 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/util/javafx/ReadWriteComposedProperty.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/util/javafx/ReadWriteComposedProperty.java @@ -1,6 +1,6 @@ /* * Hello Minecraft! Launcher - * Copyright (C) 2020 huangyuhui and contributors + * Copyright (C) 2021 huangyuhui and contributors * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -44,7 +44,11 @@ public class ReadWriteComposedProperty extends SimpleObjectProperty { this.readSource = readSource; this.writeTarget = writeTarget; - this.listener = (observable, oldValue, newValue) -> set(newValue); + this.listener = (observable, oldValue, newValue) -> { + if (!isBound()) { + set(newValue); + } + }; readSource.addListener(new WeakChangeListener<>(listener)); set(readSource.getValue()); }