mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-02-05 16:44:47 +08:00
fix: check if property is bound before setting value of ReadWriteComposedProperty
This commit is contained in:
parent
832c029db6
commit
e428cc7117
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Hello Minecraft! Launcher
|
||||
* Copyright (C) 2020 huangyuhui <huanghongxun2008@126.com> and contributors
|
||||
* Copyright (C) 2021 huangyuhui <huanghongxun2008@126.com> 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<T> extends SimpleObjectProperty<T> {
|
||||
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());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user