OpenToonz - An open-source full-featured 2D animation creation software
C
change to move thread before destructor called (#702)
tomosuac08090374b9
diff --git a/toonz/sources/stdfx/shadingcontext.cpp b/toonz/sources/stdfx/shadingcontext.cppindex 75a68bdb6..9f00d3e58 100644--- a/toonz/sources/stdfx/shadingcontext.cpp+++ b/toonz/sources/stdfx/shadingcontext.cpp@@ -14,6 +14,7 @@#include <QGLPixelBuffer>#include <QGLFramebufferObject>#include <QGLShaderProgram>+#include <QOpenGLContext>// STD includes#include <map>@@ -109,7 +110,15 @@ ShadingContext::ShadingContext() : m_imp(new Imp) {//---------------------------------------------------------ShadingContext::~ShadingContext() {}+ShadingContext::~ShadingContext() {+#ifdef MACOSX+ // Destructor of QGLPixelBuffer calls QOpenGLContext::makeCurrent() internally,+ // so the current thread must be the owner of QGLPixelBuffer context,+ // when the destructor of m_imp->m_context is called.++ m_imp->m_pixelBuffer->context()->contextHandle()->moveToThread(QThread::currentThread());+#endif+}//--------------------------------------------------------@@ -154,11 +163,21 @@ USE HARDWARE ACCELERATION*///---------------------------------------------------------void ShadingContext::makeCurrent() { m_imp->m_pixelBuffer->makeCurrent(); }+void ShadingContext::makeCurrent() {+#ifdef MACOSX+ m_imp->m_pixelBuffer->context()->contextHandle()->moveToThread(QThread::currentThread());+#endif+ m_imp->m_pixelBuffer->makeCurrent();+}//---------------------------------------------------------void ShadingContext::doneCurrent() { m_imp->m_pixelBuffer->doneCurrent(); }+void ShadingContext::doneCurrent() {+#ifdef MACOSX+ m_imp->m_pixelBuffer->context()->contextHandle()->moveToThread(0);+#endif+ m_imp->m_pixelBuffer->doneCurrent();+}//--------------------------------------------------------