From 890f0476b144af041d7641322c10bfa1e0a58931 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Wed, 4 Jun 2025 15:23:48 +0200 Subject: [PATCH] introduce delay before closing capture library --- .../java/com/sparrowwallet/sparrow/control/QRScanDialog.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/control/QRScanDialog.java b/src/main/java/com/sparrowwallet/sparrow/control/QRScanDialog.java index 608468c7..921a1e12 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/QRScanDialog.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/QRScanDialog.java @@ -31,6 +31,7 @@ import com.sparrowwallet.sparrow.io.Config; import com.sparrowwallet.sparrow.io.bbqr.BBQRDecoder; import com.sparrowwallet.sparrow.io.bbqr.BBQRException; import com.sparrowwallet.sparrow.wallet.KeystoreController; +import io.reactivex.Observable; import javafx.application.Platform; import javafx.beans.property.DoubleProperty; import javafx.beans.property.ObjectProperty; @@ -57,6 +58,7 @@ import java.nio.charset.CharsetDecoder; import java.nio.charset.StandardCharsets; import java.util.*; import java.util.List; +import java.util.concurrent.TimeUnit; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; @@ -201,7 +203,8 @@ public class QRScanDialog extends Dialog { Platform.runLater(() -> { webcamResolutionProperty.set(null); - webcamService.close(); + Observable.just(this).delay(500, TimeUnit.MILLISECONDS) + .subscribe(_ -> webcamService.close(), throwable -> log.error("Error closing webcam", throwable)); }); });