Prevent crash when sync list somehow contains None

I couldn't figure out how it could ever contain None, but we received logs from a user that indicate a crash here because that set contains None and that is not orderable. This is a hotfix to fail more gracefully instead of crashing the entire application.
This commit is contained in:
Ghostkeeper 2019-10-24 10:59:37 +02:00
parent b9b086a8c0
commit 969b74e1f6
No known key found for this signature in database
GPG key ID: 59A4C0959592C05C

View file

@ -220,6 +220,9 @@ class PrinterOutputDevice(QObject, OutputDevice):
if printer.printerConfiguration is not None and printer.printerConfiguration.hasAnyMaterialLoaded():
all_configurations.add(printer.printerConfiguration)
all_configurations.update(printer.availableConfigurations)
if None in all_configurations: # Shouldn't happen, but it do. I don't see how it could ever happen. Skip adding that configuration. List could end up empty!
Logger.log("e", "Found a broken configuration in the synced list!")
all_configurations.remove(None)
new_configurations = sorted(all_configurations, key = lambda config: config.printerType or "")
if new_configurations != self._unique_configurations:
self._unique_configurations = new_configurations