diff --git a/gui/qt/qrtextedit.py b/gui/qt/qrtextedit.py index eb9e8bf90ca7..66def42c8909 100644 --- a/gui/qt/qrtextedit.py +++ b/gui/qt/qrtextedit.py @@ -56,6 +56,8 @@ def qr_input(self): except BaseException as e: self.show_error(str(e)) data = '' + if not data: + data = '' self.setText(data) return data diff --git a/lib/qrscanner.py b/lib/qrscanner.py index f659d5e46c11..7516d55d5716 100644 --- 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)