diff --git a/plugins/platforms/drm/drm_output.h b/plugins/platforms/drm/drm_output.h --- a/plugins/platforms/drm/drm_output.h +++ b/plugins/platforms/drm/drm_output.h @@ -61,6 +61,7 @@ QSize physicalSize; }; virtual ~DrmOutput(); + void cleanup(); void showCursor(DrmBuffer *buffer); void hideCursor(); void moveCursor(const QPoint &globalPos); diff --git a/plugins/platforms/drm/drm_output.cpp b/plugins/platforms/drm/drm_output.cpp --- a/plugins/platforms/drm/drm_output.cpp +++ b/plugins/platforms/drm/drm_output.cpp @@ -69,6 +69,16 @@ delete m_waylandOutputDevice.data(); } +void DrmOutput::cleanup() +{ + if (m_currentBuffer) { + m_currentBuffer->releaseGbm(); + } + if (m_primaryPlane && m_primaryPlane->current()) { + m_primaryPlane->current()->releaseGbm(); + } +} + void DrmOutput::hideCursor() { drmModeSetCursor(m_backend->fd(), m_crtcId, 0, 0, 0); @@ -673,9 +683,7 @@ m_planesFlipList.clear(); } else { - if (!m_nextBuffer) { - return; - } + Q_ASSERT(m_nextBuffer); pageFlippedBufferRemover(m_currentBuffer, m_nextBuffer); m_currentBuffer = m_nextBuffer; m_nextBuffer = nullptr; @@ -685,14 +693,8 @@ void DrmOutput::pageFlippedBufferRemover(DrmBuffer *oldbuffer, DrmBuffer *newbuffer) { - if (newbuffer->deleteAfterPageFlip()) { - if ( oldbuffer && oldbuffer != newbuffer ) { - delete oldbuffer; - } - } else { - // although oldbuffer's pointer is remapped in pageFlipped(), - // we ignore the pointer completely anywhere else in this case - newbuffer->releaseGbm(); + if (oldbuffer && oldbuffer->deleteAfterPageFlip() && oldbuffer != newbuffer) { + delete oldbuffer; } } diff --git a/plugins/platforms/drm/egl_gbm_backend.cpp b/plugins/platforms/drm/egl_gbm_backend.cpp --- a/plugins/platforms/drm/egl_gbm_backend.cpp +++ b/plugins/platforms/drm/egl_gbm_backend.cpp @@ -62,7 +62,6 @@ EglGbmBackend::~EglGbmBackend() { - // TODO: cleanup front buffer? cleanup(); } @@ -75,7 +74,8 @@ void EglGbmBackend::cleanupOutput(const Output &o) { - // TODO: cleanup front buffer? + o.output->cleanup(); + if (o.eglSurface != EGL_NO_SURFACE) { eglDestroySurface(eglDisplay(), o.eglSurface); }