eglfs-kms/gbm: fix segfault and add qScopeGuard
As framebufferForBufferObject has a code-path which returns a nullptr, it's vital to check on that and return early in that case. As this is the second segment in this function that does gbm_surface_release_buffer, a qScopeGuard was introduced to reduce code duplication. This also makes this function saver/easier to maintain long term. The platform on which this segfault was reported is QEMU Change-Id: I5ee1ad4073712349b7475bce3a7978961fea2344 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> (cherry picked from commit ad2aca113daccb4d0e9299b7c37d61f2d9b1f930)
This commit is contained in:
parent
c3f04ebfa9
commit
cc295aac1f
@ -349,7 +349,17 @@ void QEglFSKmsGbmScreen::flip()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto gbmRelease = qScopeGuard([this]{
|
||||||
|
m_flipPending = false;
|
||||||
|
gbm_surface_release_buffer(m_gbm_surface, m_gbm_bo_next);
|
||||||
|
m_gbm_bo_next = nullptr;
|
||||||
|
});
|
||||||
|
|
||||||
FrameBuffer *fb = framebufferForBufferObject(m_gbm_bo_next);
|
FrameBuffer *fb = framebufferForBufferObject(m_gbm_bo_next);
|
||||||
|
if (!fb) {
|
||||||
|
qWarning("FrameBuffer not available. Cannot flip");
|
||||||
|
return;
|
||||||
|
}
|
||||||
ensureModeSet(fb->fb);
|
ensureModeSet(fb->fb);
|
||||||
|
|
||||||
const QKmsOutput &thisOutput(output());
|
const QKmsOutput &thisOutput(output());
|
||||||
@ -381,9 +391,6 @@ void QEglFSKmsGbmScreen::flip()
|
|||||||
this);
|
this);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
qErrnoWarning("Could not queue DRM page flip on screen %s", qPrintable(name()));
|
qErrnoWarning("Could not queue DRM page flip on screen %s", qPrintable(name()));
|
||||||
m_flipPending = false;
|
|
||||||
gbm_surface_release_buffer(m_gbm_surface, m_gbm_bo_next);
|
|
||||||
m_gbm_bo_next = nullptr;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -426,6 +433,8 @@ void QEglFSKmsGbmScreen::flip()
|
|||||||
#if QT_CONFIG(drm_atomic)
|
#if QT_CONFIG(drm_atomic)
|
||||||
device()->threadLocalAtomicCommit(this);
|
device()->threadLocalAtomicCommit(this);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
gbmRelease.dismiss();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QEglFSKmsGbmScreen::flipFinished()
|
void QEglFSKmsGbmScreen::flipFinished()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user