Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Ultimaker/Cura.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGhostkeeper <rubend@tutanota.com>2020-04-23 14:41:06 +0300
committerGhostkeeper <rubend@tutanota.com>2020-04-23 14:41:06 +0300
commit75aafa1e5cd593b97feac7cea14eeafd01dc3df6 (patch)
tree19069f7b4b5b1ee40d0656820262410e67a624f6 /plugins/SolidView
parent29d2e5c92112737f371b066a42c02228cb4267ae (diff)
Don't crash if rendering without any window
Probably it'll still crash somewhere else then, but we'll rely on Sentry to find that for us. Fixes Sentry issue CURA-KW.
Diffstat (limited to 'plugins/SolidView')
-rw-r--r--plugins/SolidView/SolidView.py24
1 files changed, 17 insertions, 7 deletions
diff --git a/plugins/SolidView/SolidView.py b/plugins/SolidView/SolidView.py
index bd8215aba5..09d27859b5 100644
--- a/plugins/SolidView/SolidView.py
+++ b/plugins/SolidView/SolidView.py
@@ -267,13 +267,23 @@ class SolidView(View):
Class that ducktypes to be a Numpy ndarray.
"""
def __init__(self, qimage):
- self.__array_interface__ = {
- "shape": (qimage.height(), qimage.width()),
- "typestr": "|u4", # Use 4 bytes per pixel rather than 3, since Numpy doesn't support 3.
- "data": (int(qimage.bits()), False),
- "strides": (qimage.bytesPerLine(), 3), # This does the magic: For each line, skip the correct number of bytes. Bytes per pixel is always 3 due to QImage.Format.Format_RGB888.
- "version": 3
- }
+ bits_pointer = qimage.bits()
+ if bits_pointer is None: # If this happens before there is a window.
+ self.__array_interface__ = {
+ "shape": (0, 0),
+ "typestr": "|u4",
+ "data": (0, False),
+ "strides": (1, 3),
+ "version": 3
+ }
+ else:
+ self.__array_interface__ = {
+ "shape": (qimage.height(), qimage.width()),
+ "typestr": "|u4", # Use 4 bytes per pixel rather than 3, since Numpy doesn't support 3.
+ "data": (int(bits_pointer), False),
+ "strides": (qimage.bytesPerLine(), 3), # This does the magic: For each line, skip the correct number of bytes. Bytes per pixel is always 3 due to QImage.Format.Format_RGB888.
+ "version": 3
+ }
array = np.asarray(QImageArrayView(xray_img)).view(np.dtype({
"r": (np.uint8, 0, "red"),
"g": (np.uint8, 1, "green"),