From a934ffa76c4421eaf65e1a632047ecee88526371 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Mon, 27 Sep 2021 11:46:50 +0200 Subject: [PATCH] fix issues when removing selected items from utxotreetable --- .../sparrowwallet/sparrow/wallet/UtxosController.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/wallet/UtxosController.java b/src/main/java/com/sparrowwallet/sparrow/wallet/UtxosController.java index ef849563..00d9dfd1 100644 --- a/src/main/java/com/sparrowwallet/sparrow/wallet/UtxosController.java +++ b/src/main/java/com/sparrowwallet/sparrow/wallet/UtxosController.java @@ -30,6 +30,7 @@ import javafx.fxml.FXML; import javafx.fxml.Initializable; import javafx.scene.control.Button; import javafx.scene.control.Tooltip; +import javafx.scene.control.TreeItem; import javafx.scene.layout.HBox; import javafx.stage.FileChooser; import javafx.stage.Stage; @@ -192,7 +193,9 @@ public class UtxosController extends WalletFormController implements Initializab } private List getSelectedEntries() { - return utxosTable.getSelectionModel().getSelectedCells().stream().map(tp -> (UtxoEntry)tp.getTreeItem().getValue()) + return utxosTable.getSelectionModel().getSelectedCells().stream() + .filter(tp -> tp.getTreeItem() != null) + .map(tp -> (UtxoEntry)tp.getTreeItem().getValue()) .filter(utxoEntry -> utxoEntry.isSpendable() && !utxoEntry.isMixing()) .collect(Collectors.toList()); } @@ -445,9 +448,15 @@ public class UtxosController extends WalletFormController implements Initializab if(event.getWallet().equals(walletForm.getWallet())) { WalletUtxosEntry walletUtxosEntry = getWalletForm().getWalletUtxosEntry(); + List selectedEntries = utxosTable.getSelectionModel().getSelectedItems().stream().map(TreeItem::getValue).filter(Objects::nonNull).toList(); + //Will automatically update utxosTable walletUtxosEntry.updateUtxos(); + if(!walletUtxosEntry.getChildren().containsAll(selectedEntries)) { + utxosTable.getSelectionModel().clearSelection(); + } + utxosTable.updateHistory(event.getHistoryChangedNodes()); utxosChart.update(walletUtxosEntry); }