introduce delay before closing capture library

This commit is contained in:
Craig Raw 2025-06-04 15:23:48 +02:00
parent 4d93381124
commit 890f0476b1

View file

@ -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<QRScanDialog.Result> {
Platform.runLater(() -> {
webcamResolutionProperty.set(null);
webcamService.close();
Observable.just(this).delay(500, TimeUnit.MILLISECONDS)
.subscribe(_ -> webcamService.close(), throwable -> log.error("Error closing webcam", throwable));
});
});