mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-09-30 00:56:56 +13:00
Fix NPE on file rename undo
This commit is contained in:
parent
ba295e975e
commit
a9ce57f6c5
1 changed files with 14 additions and 5 deletions
|
@ -12,6 +12,8 @@ import javafx.scene.layout.StackPane;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Value;
|
import lombok.Value;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class LazyTextFieldComp extends Comp<LazyTextFieldComp.Structure> {
|
public class LazyTextFieldComp extends Comp<LazyTextFieldComp.Structure> {
|
||||||
|
|
||||||
private final Property<String> currentValue;
|
private final Property<String> currentValue;
|
||||||
|
@ -53,9 +55,8 @@ public class LazyTextFieldComp extends Comp<LazyTextFieldComp.Structure> {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Handles external updates
|
// Handles external updates
|
||||||
PlatformThread.sync(appliedValue).addListener((observable, oldValue, newValue) -> {
|
PlatformThread.sync(appliedValue).addListener((observable, oldValue, n) -> {
|
||||||
r.setText(newValue);
|
currentValue.setValue(n);
|
||||||
currentValue.setValue(newValue);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
r.setPrefWidth(0);
|
r.setPrefWidth(0);
|
||||||
|
@ -64,8 +65,16 @@ public class LazyTextFieldComp extends Comp<LazyTextFieldComp.Structure> {
|
||||||
sp.prefHeightProperty().bind(r.prefHeightProperty());
|
sp.prefHeightProperty().bind(r.prefHeightProperty());
|
||||||
r.setDisable(true);
|
r.setDisable(true);
|
||||||
|
|
||||||
SimpleChangeListener.apply(currentValue, val -> {
|
SimpleChangeListener.apply(currentValue, n -> {
|
||||||
PlatformThread.runLaterIfNeeded(() -> r.setText(val));
|
PlatformThread.runLaterIfNeeded(() -> {
|
||||||
|
// Check if control value is the same. Then don't set it as that might cause bugs
|
||||||
|
if (Objects.equals(r.getText(), n)
|
||||||
|
|| (n == null && r.getText().isEmpty())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
r.setText(n);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
r.textProperty().addListener((observable, oldValue, newValue) -> {
|
r.textProperty().addListener((observable, oldValue, newValue) -> {
|
||||||
currentValue.setValue(newValue);
|
currentValue.setValue(newValue);
|
||||||
|
|
Loading…
Reference in a new issue