Add extra exception handling for UFPwriter

This commit is contained in:
Jaime van Kessel 2019-09-24 09:24:36 +02:00
parent fae4138b79
commit 3ab0b5decf
No known key found for this signature in database
GPG key ID: 3710727397403C91
2 changed files with 9 additions and 3 deletions

View file

@ -85,8 +85,10 @@ class Snapshot:
preview_pass.setCamera(camera) preview_pass.setCamera(camera)
preview_pass.render() preview_pass.render()
pixel_output = preview_pass.getOutput() pixel_output = preview_pass.getOutput()
try:
min_x, max_x, min_y, max_y = Snapshot.getImageBoundaries(pixel_output) min_x, max_x, min_y, max_y = Snapshot.getImageBoundaries(pixel_output)
except ValueError:
return None
size = max((max_x - min_x) / render_width, (max_y - min_y) / render_height) size = max((max_x - min_x) / render_width, (max_y - min_y) / render_height)
if size > 0.5 or satisfied: if size > 0.5 or satisfied:

View file

@ -38,7 +38,11 @@ class UFPWriter(MeshWriter):
def _createSnapshot(self, *args): def _createSnapshot(self, *args):
# must be called from the main thread because of OpenGL # must be called from the main thread because of OpenGL
Logger.log("d", "Creating thumbnail image...") Logger.log("d", "Creating thumbnail image...")
self._snapshot = Snapshot.snapshot(width = 300, height = 300) try:
self._snapshot = Snapshot.snapshot(width = 300, height = 300)
except Exception:
Logger.logException("w", "Failed to create snapshot image")
self._snapshot = None # Failing to create thumbnail should not fail creation of UFP
# This needs to be called on the main thread (Qt thread) because the serialization of material containers can # This needs to be called on the main thread (Qt thread) because the serialization of material containers can
# trigger loading other containers. Because those loaded containers are QtObjects, they must be created on the # trigger loading other containers. Because those loaded containers are QtObjects, they must be created on the