Skip to content

Commit 239652d

Browse files
committed
Fix video qt shutdown
1 parent 3946685 commit 239652d

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

examples/video/qt/grid.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ def close():
3131
logging.info("Stopping all cameras...")
3232
for qcamera in qcameras:
3333
qcamera.stop()
34-
logging.info("waiting for cameras to stop...")
35-
for qcamera in qcameras:
36-
qcamera.wait()
3734
logging.info("Done!")
3835

3936
app = QtWidgets.QApplication([])

linuxpy/video/qt.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def __init__(self, device: Device):
2727
self.capture = VideoCapture(device)
2828
self._stop = False
2929
self._stream = None
30+
self._notifier = None
3031
self._state = "stopped"
3132

3233
def on_frame(self):
@@ -63,8 +64,12 @@ def resume(self):
6364
self.setState("running")
6465

6566
def stop(self):
66-
self._notifier.setEnabled(False)
67-
self._stream.close()
67+
if self._notifier is not None:
68+
self._notifier.setEnabled(False)
69+
self._notifier = None
70+
if self._stream is not None:
71+
self._stream.close()
72+
self._stream = None
6873
self.capture.close()
6974
self.device.close()
7075
self._notifier = None

0 commit comments

Comments
 (0)