Commit cc938b8c authored by Daniel Vrátil's avatar Daniel Vrátil 🤖

Fix crash when initializing offscreen surface in GLWidget

GLWidget::initializeGL() is called in renderer thread so the QOffscreenSurface must
also live in the renderer thread.

Differential Revision: https://phabricator.kde.org/D11509
parent c4b87e85
......@@ -83,6 +83,7 @@ GLWidget::GLWidget(int id, QObject *parent)
, m_openGLSync(false)
, m_sendFrame(false)
, m_offset(QPoint(0, 0))
, m_offscreenSurface(nullptr)
, m_shareContext(nullptr)
, m_audioWaveDisplayed(false)
, m_fbo(nullptr)
......@@ -132,6 +133,7 @@ GLWidget::~GLWidget()
delete m_frameRenderer;
}
}
delete m_offscreenSurface;
delete m_shareContext;
delete m_shader;
delete m_monitorProfile;
......@@ -147,9 +149,10 @@ void GLWidget::updateAudioForAnalysis()
void GLWidget::initializeGL()
{
if (m_isInitialized || !isVisible() || !openglContext()) return;
if (!m_offscreenSurface.isValid()) {
m_offscreenSurface.setFormat(openglContext()->format());
m_offscreenSurface.create();
if (!m_offscreenSurface) {
m_offscreenSurface = new QOffscreenSurface();
m_offscreenSurface->setFormat(openglContext()->format());
m_offscreenSurface->create();
openglContext()->makeCurrent(this);
}
initializeOpenGLFunctions();
......@@ -198,7 +201,7 @@ void GLWidget::initializeGL()
m_shareContext->setShareContext(openglContext());
m_shareContext->create();
}
m_frameRenderer = new FrameRenderer(openglContext(), &m_offscreenSurface);
m_frameRenderer = new FrameRenderer(openglContext(), m_offscreenSurface);
m_frameRenderer->sendAudioForAnalysis = KdenliveSettings::monitor_audio();
openglContext()->makeCurrent(this);
//openglContext()->blockSignals(false);
......@@ -634,7 +637,7 @@ void GLWidget::createThread(RenderThread **thread, thread_function_t function, v
m_initSem.acquire();
}
#endif
(*thread) = new RenderThread(function, data, m_shareContext, &m_offscreenSurface);
(*thread) = new RenderThread(function, data, m_shareContext, m_offscreenSurface);
(*thread)->start();
}
......
......@@ -184,7 +184,7 @@ private:
SharedFrame m_sharedFrame;
QMutex m_mutex;
QPoint m_offset;
QOffscreenSurface m_offscreenSurface;
QOffscreenSurface *m_offscreenSurface;
QOpenGLContext *m_shareContext;
bool m_audioWaveDisplayed;
static void on_frame_show(mlt_consumer, void *self, mlt_frame frame);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment