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();
}
}
}
+2
View File
@@ -44,6 +44,8 @@ public:
virtual bool Init() override;
virtual void PostDestroy() override;
public slots:
virtual void PostInit() override;
+2
View File
@@ -67,6 +67,8 @@ public:
void Destroy();
virtual void PostDestroy() = 0;
public slots:
virtual void PostInit() = 0;
+3 -1
View File
@@ -58,12 +58,14 @@ void RendererThreadWrapper::DestroyInternal()
{
if (thread_) {
QMetaObject::invokeMethod(inner_, "DestroyInternal", Qt::BlockingQueuedConnection);
inner_ = nullptr;
thread_->quit();
thread_->wait();
delete thread_;
thread_ = nullptr;
// Destroy in main thread
inner_->PostDestroy();
}
}
+3
View File
@@ -35,11 +35,14 @@ public:
virtual ~RendererThreadWrapper() override
{
Destroy();
PostDestroy();
delete inner_;
}
virtual bool Init() override;
virtual void PostDestroy() override {}
public slots:
virtual void PostInit() override;
+1
View File
@@ -75,6 +75,7 @@ RenderManager::~RenderManager()
delete still_cache_;
context_->Destroy();
context_->PostDestroy();
delete context_;
}
}
@@ -208,6 +208,7 @@ void ManagedDisplayWidget::MenuColorspaceSelect(QAction *action)
void ManagedDisplayWidget::OnDestroy()
{
attached_renderer_->Destroy();
attached_renderer_->PostDestroy();
}
void ManagedDisplayWidget::SetColorTransform(const ColorTransform &transform)