Don't crash if the shader fails to compile

This commit is contained in:
Ghostkeeper 2020-05-01 17:49:29 +02:00
parent 245a4435e1
commit 51378cae56
No known key found for this signature in database
GPG Key ID: D2A8871EE34EC59A
2 changed files with 12 additions and 3 deletions

View File

@ -1,14 +1,16 @@
# Copyright (c) 2018 Ultimaker B.V.
# Copyright (c) 2020 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher.
from typing import Optional, TYPE_CHECKING
from UM.Qt.QtApplication import QtApplication
from UM.Logger import Logger
from UM.Math.Vector import Vector
from UM.Resources import Resources
from UM.View.RenderPass import RenderPass
from UM.View.GL.OpenGL import OpenGL
from UM.View.GL.ShaderProgram import InvalidShaderProgramError
from UM.View.RenderBatch import RenderBatch
from UM.Scene.Iterator.DepthFirstIterator import DepthFirstIterator
@ -31,7 +33,11 @@ class PickingPass(RenderPass):
def render(self) -> None:
if not self._shader:
try:
self._shader = OpenGL.getInstance().createShaderProgram(Resources.getPath(Resources.Shaders, "camera_distance.shader"))
except InvalidShaderProgramError:
Logger.error("Unable to compile shader program: camera_distance.shader")
return
width, height = self.getSize()
self._gl.glViewport(0, 0, width, height)

View File

@ -1,10 +1,11 @@
# Copyright (c) 2018 Ultimaker B.V.
# Copyright (c) 2020 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher.
from typing import Optional, TYPE_CHECKING, cast
from UM.Application import Application
from UM.Logger import Logger
from UM.Resources import Resources
from UM.View.RenderPass import RenderPass
@ -63,6 +64,8 @@ class PreviewPass(RenderPass):
self._shader.setUniformValue("u_shininess", 20.0)
self._shader.setUniformValue("u_renderError", 0.0) # We don't want any error markers!.
self._shader.setUniformValue("u_faceId", -1) # Don't render any selected faces in the preview.
else:
Logger.error("Unable to compile shader program: overhang.shader")
if not self._non_printing_shader:
if self._non_printing_shader: