renderer: destroy surface in main thread
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -44,6 +44,8 @@ public:
|
||||
|
||||
virtual bool Init() override;
|
||||
|
||||
virtual void PostDestroy() override;
|
||||
|
||||
public slots:
|
||||
virtual void PostInit() override;
|
||||
|
||||
|
||||
@@ -67,6 +67,8 @@ public:
|
||||
|
||||
void Destroy();
|
||||
|
||||
virtual void PostDestroy() = 0;
|
||||
|
||||
public slots:
|
||||
virtual void PostInit() = 0;
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user