commit f70408cef5eff3eead108a06ee11a6106253f74d
parent 7ed79011fe954c6bfe9a123372f489067cb1b555
Author: ThomasV <thomasv@electrum.org>
Date: Fri, 25 Aug 2017 11:23:11 +0200
fix ctypes for zbar qrcode scanner
Diffstat:
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/lib/qrscanner.py b/lib/qrscanner.py
@@ -25,7 +25,7 @@
import os
import sys
-from ctypes import cdll, c_char_p
+import ctypes
if sys.platform == 'darwin':
name = 'libzbar.dylib'
@@ -35,7 +35,7 @@ else:
name = 'libzbar.so.0'
try:
- libzbar = cdll.LoadLibrary(name)
+ libzbar = ctypes.cdll.LoadLibrary(name)
except OSError:
libzbar = None
@@ -43,7 +43,10 @@ except OSError:
def scan_barcode(device='', timeout=-1, display=True, threaded=False):
if libzbar is None:
raise RuntimeError("Cannot start QR scanner; zbar not available.")
- libzbar.zbar_symbol_get_data.restype = c_char_p
+ libzbar.zbar_symbol_get_data.restype = ctypes.c_char_p
+ libzbar.zbar_processor_create.restype = ctypes.POINTER(ctypes.c_int)
+ libzbar.zbar_processor_get_results.restype = ctypes.POINTER(ctypes.c_int)
+ 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)