Merge lp:~chciken/qr-tools/fix-index-error into lp:qr-tools

Proposed by Niko Zurstraßen
Status: Merged
Approved by: Ramiro Algozino
Approved revision: 44
Merged at revision: 44
Proposed branch: lp:~chciken/qr-tools/fix-index-error
Merge into: lp:qr-tools
Diff against target: 37 lines (+18/-7)
1 file modified
qtqr.py (+18/-7)
To merge this branch: bzr merge lp:~chciken/qr-tools/fix-index-error
Reviewer Review Type Date Requested Status
Ramiro Algozino Approve
Review via email: mp+395971@code.launchpad.net

Commit message

Wrapping a try/except block around data_decode.
This fixes segmentation faults which might occur when decoding broken qr codes with a webcam.

Description of the change

This fixes bug #1909309.

To post a comment you must log in.
Revision history for this message
Ramiro Algozino (algozino) wrote :

lgtm. Thank you for taking care of this.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'qtqr.py'
--- qtqr.py 2020-10-24 11:53:42 +0000
+++ qtqr.py 2021-01-08 07:15:30 +0000
@@ -897,15 +897,26 @@
897 if device:897 if device:
898 qr = QR()898 qr = QR()
899 qr.decode_webcam(device=device)899 qr.decode_webcam(device=device)
900 if qr.data_decode[qr.data_type](qr.data) == 'NULL':900 try:
901 QtWidgets.QMessageBox.warning(901 matchData = qr.data_decode[qr.data_type](qr.data)
902 self,902 except IndexError:
903 self.tr("Decoding Failed"),903 QtWidgets.QMessageBox.warning(
904 self.tr("<p>Oops! no code was found.<br /> Maybe your webcam didn't focus.</p>"),904 self,
905 QtWidgets.QMessageBox.Ok905 self.tr("Decoding Failed"),
906 self.tr(f"<p>oops! Your code seems to be of type '{qr.data_type}', but no decoding for data '{qr.data}' could be found.</p>"),
907 QtWidgets.QMessageBox.Ok
906 )908 )
907 else:909 else:
908 self.showInfo(qr)910 if matchData == 'NULL':
911 QtWidgets.QMessageBox.warning(
912 self,
913 self.tr("Decoding Failed"),
914 self.tr("<p>Oops! no code was found.<br /> Maybe your webcam didn't focus.</p>"),
915 QtWidgets.QMessageBox.Ok
916 )
917 else:
918 self.showInfo(qr)
919
909 qr.destroy()920 qr.destroy()
910921
911 def about(self):922 def about(self):

Subscribers

People subscribed via source and target branches