Fix crash when port gets disconnected while iterating

Fixes Sentry issue CURA-11T.
This commit is contained in:
Ghostkeeper 2020-07-20 12:10:08 +02:00
parent 528c8e2226
commit 8c4533a2c3
No known key found for this signature in database
GPG key ID: D2A8871EE34EC59A

View file

@ -1,4 +1,4 @@
# Copyright (c) 2018 Ultimaker B.V. # Copyright (c) 2020 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher. # Cura is released under the terms of the LGPLv3 or higher.
import threading import threading
@ -117,6 +117,8 @@ class USBPrinterOutputDeviceManager(QObject, OutputDevicePlugin):
for port in serial.tools.list_ports.comports(): for port in serial.tools.list_ports.comports():
if not isinstance(port, tuple): if not isinstance(port, tuple):
port = (port.device, port.description, port.hwid) port = (port.device, port.description, port.hwid)
if not port[2]: # HWID may be None if the port got disconnected while processing.
continue
if only_list_usb and not port[2].startswith("USB"): if only_list_usb and not port[2].startswith("USB"):
continue continue