renderer: destroy surface in main thread

This commit is contained in:
itsmattkc
2020-11-25 08:59:14 +11:00
parent 1254726079
commit 0eda91a0cb
7 changed files with 21 additions and 6 deletions
+9 -5
View File
@@ -82,6 +82,7 @@ OpenGLRenderer::OpenGLRenderer(QObject* parent) :
OpenGLRenderer::~OpenGLRenderer()
{
Destroy();
PostDestroy();
}
void OpenGLRenderer::Init(QOpenGLContext *existing_ctx)
@@ -114,6 +115,14 @@ bool OpenGLRenderer::Init()
return true;
}
void OpenGLRenderer::PostDestroy()
{
// Destroy surface if we created it
if (surface_.isValid()) {
surface_.destroy();
}
}
void OpenGLRenderer::PostInit()
{
// Make context current on that surface
@@ -142,11 +151,6 @@ void OpenGLRenderer::DestroyInternal()
delete context_;
}
context_ = nullptr;
// Destroy surface if we created it
if (surface_.isValid()) {
surface_.destroy();
}
}
}