OpenToonz - An open-source full-featured 2D animation creation software
C
stop using global context (#1785)
shun-iwasawab08db1990c4f
diff --git a/toonz/sources/common/tfx/trenderer.cpp b/toonz/sources/common/tfx/trenderer.cppindex 638e3109c..60ea39323 100644--- a/toonz/sources/common/tfx/trenderer.cpp+++ b/toonz/sources/common/tfx/trenderer.cpp@@ -1424,8 +1424,6 @@ void TRendererImp::startRendering(QThread::currentThread() == qGuiApp->thread()) {rs.m_offScreenSurface.reset(new QOffscreenSurface());rs.m_offScreenSurface->setFormat(QSurfaceFormat::defaultFormat());- rs.m_offScreenSurface->setScreen(- QOpenGLContext::globalShareContext()->screen());rs.m_offScreenSurface->create();}diff --git a/toonz/sources/tcomposer/tcomposer.cpp b/toonz/sources/tcomposer/tcomposer.cppindex 5c0bf88cc..e38633cf4 100644--- a/toonz/sources/tcomposer/tcomposer.cpp+++ b/toonz/sources/tcomposer/tcomposer.cpp@@ -564,7 +564,6 @@ static std::pair<int, int> generateMovie(ToonzScene *scene, const TFilePath &fp,DV_IMPORT_API void initStdFx();DV_IMPORT_API void initColorFx();int main(int argc, char *argv[]) {- QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts);QApplication app(argc, argv);// Create a QObject destroyed just before app - see Tnz6's main.cpp fordiff --git a/toonz/sources/toonz/main.cpp b/toonz/sources/toonz/main.cppindex 36197422b..34f6edde4 100644--- a/toonz/sources/toonz/main.cpp+++ b/toonz/sources/toonz/main.cpp@@ -259,9 +259,6 @@ int main(int argc, char *argv[]) {#if QT_VERSION >= 0x050600QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);#endif- // Enables resource sharing between the OpenGL contexts used by classes like- // QOpenGLWidget and QQuickWidget.- QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts);QApplication a(argc, argv);diff --git a/toonz/sources/toonzlib/imagebuilders.cpp b/toonz/sources/toonzlib/imagebuilders.cppindex 5d48b7d99..3e25b73ec 100644--- a/toonz/sources/toonzlib/imagebuilders.cpp+++ b/toonz/sources/toonzlib/imagebuilders.cpp@@ -277,8 +277,6 @@ TImageP ImageRasterizer::build(int imFlags, void *extData) {std::unique_ptr<QOffscreenSurface> surface(new QOffscreenSurface());surface->setFormat(format);- // Enabling Qt::AA_ShareOpenGLContexts attribute in main()- surface->setScreen(QOpenGLContext::globalShareContext()->screen());surface->create();TRaster32P ras(d);diff --git a/toonz/sources/toonzlib/plasticdeformerfx.cpp b/toonz/sources/toonzlib/plasticdeformerfx.cppindex 9f3ea0ca5..2a2b98193 100644--- a/toonz/sources/toonzlib/plasticdeformerfx.cpp+++ b/toonz/sources/toonzlib/plasticdeformerfx.cpp@@ -363,7 +363,8 @@ void PlasticDeformerFx::doCompute(TTile &tile, double frame,// Prepare an OpenGL contextcontext = new QOpenGLContext();- context->setShareContext(QOpenGLContext::globalShareContext());+ if (QOpenGLContext::currentContext())+ context->setShareContext(QOpenGLContext::currentContext());context->setFormat(QSurfaceFormat::defaultFormat());context->create();context->makeCurrent(info.m_offScreenSurface.get());diff --git a/toonz/sources/toonzlib/toonzscene.cpp b/toonz/sources/toonzlib/toonzscene.cppindex 60a3ccc7b..e36d56c03 100644--- a/toonz/sources/toonzlib/toonzscene.cpp+++ b/toonz/sources/toonzlib/toonzscene.cpp@@ -811,8 +811,6 @@ void ToonzScene::renderFrame(const TRaster32P &ras, int row, const TXsheet *xsh,std::unique_ptr<QOffscreenSurface> surface(new QOffscreenSurface());surface->setFormat(format);- // Enabling Qt::AA_ShareOpenGLContexts attribute in main()- surface->setScreen(QOpenGLContext::globalShareContext()->screen());surface->create();glPushAttrib(GL_ALL_ATTRIB_BITS);