Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CURA-12309 hard crash when modifying a post processing setting value with auto slice #991

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions UM/View/GL/OpenGL.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ def __init__(self) -> None:
profile.setVersion(OpenGLContext.major_version, OpenGLContext.minor_version)
profile.setProfile(OpenGLContext.profile)

context = QOpenGLContext.currentContext()
if not context:
self._context = QOpenGLContext.currentContext()
if not self._context:
Logger.log("e", "Startup failed due to OpenGL context creation failing")
QOpenGLContext.currentContext()
sys.exit(1)
self._gl = QOpenGLVersionFunctionsFactory.get(profile, context)
self._gl = QOpenGLVersionFunctionsFactory.get(profile, self._context)
if not self._gl:
Logger.log("e", "Startup failed due to OpenGL initialization failing")
QMessageBox.critical(QMessageBox.Icon.Critical, "Failed to Initialize OpenGL", i18n_catalog.i18nc("@message", "Failed to Initialize OpenGL", "Could not initialize OpenGL. This program requires OpenGL 2.0 or higher. Please check your video card drivers."))
Expand Down Expand Up @@ -340,6 +340,14 @@ def createIndexBuffer(self, mesh: "MeshData", **kwargs: Any):

__instance = None # type: OpenGL

def activateContext(self):
"""
Make sure the OpenGL is currently active. This should be called every time before starting an OpenGL rendering
with this object
"""
from UM.Qt.QtApplication import QtApplication
self._context.makeCurrent(QtApplication.getInstance().getMainWindow())

@classmethod
def getInstance(cls, *args, **kwargs) -> "OpenGL":
return cls.__instance
2 changes: 2 additions & 0 deletions UM/View/RenderBatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ def render(self, camera: Optional[Camera]):
Logger.log("e", "Unable to render batch without a camera.")
return

OpenGL.getInstance().activateContext()

self._shader.bind()

if self._backface_cull:
Expand Down
Loading