commit 189779711dffd6bc6532b88709bc4798c981d4b6
parent f231349673285e7a70465dc1726c4243f9a35d98
Author: ThomasV <thomasv@electrum.org>
Date: Mon, 18 Dec 2017 08:07:36 +0100
Merge pull request #3546 from cb8/fix-qrscanner
qrscanner: Fix segfault when using a specific camera device
Diffstat:
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lib/qrscanner.py b/lib/qrscanner.py
@@ -49,7 +49,8 @@ def scan_barcode(device='', timeout=-1, display=True, threaded=False):
libzbar.zbar_symbol_set_first_symbol.restype = ctypes.POINTER(ctypes.c_int)
proc = libzbar.zbar_processor_create(threaded)
libzbar.zbar_processor_request_size(proc, 640, 480)
- libzbar.zbar_processor_init(proc, device, display)
+ if libzbar.zbar_processor_init(proc, device.encode('utf-8'), display) != 0:
+ raise RuntimeError("Can not start QR scanner; initialization failed.")
libzbar.zbar_processor_set_visible(proc)
if libzbar.zbar_process_one(proc, timeout):
symbols = libzbar.zbar_processor_get_results(proc)